自动化对象数据类型问题,有难度,相信大家都遇到过!

gflily 2007-04-22 09:23:22
我的COM接口(继承自idispatch)程序中要用到这样一个函数:
lm(int dr,char comm[],int chann,byte dat[]);我在IDL文件中怎么才能表达出这个函数?因为automation类型中没有char与byte这种类型!只有short ,long,bstr,variant等。难道我一定得用那个别扭的variant,我只是要一个byte类型的数组!!!自动化接口中的方法比C、C++的方法限制多啊!我怎么才能在idl中写出最适合我本意的接口方法?
...全文
435 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
shanhe972005 2007-05-24
  • 打赏
  • 举报
回复
unsigned char*应该用什么替换啊?谢了
littlegang 2007-05-23
  • 打赏
  • 举报
回复
弄错了,可以用SAFEARRAY结构
samsun2000 2007-05-23
  • 打赏
  • 举报
回复
100分告诉你方法,哈哈
littlegang 2007-05-23
  • 打赏
  • 举报
回复
VC++6 似乎还不支持SAFEARRAY吧

好像是managed C++才是有吧

不大清楚
gflily 2007-05-09
  • 打赏
  • 举报
回复
竟然结不了!!
gflily 2007-05-09
  • 打赏
  • 举报
回复
结贴给分。
gflily 2007-05-09
  • 打赏
  • 举报
回复
虽然masterz的回答没有解决问题,因为我的c++函数并不是我从idl copy过来的,我是用向导生成与idl对应的函数的,但这分给他当之无愧。
gflily 2007-04-22
  • 打赏
  • 举报
回复
我的环境是vc6
gflily 2007-04-22
  • 打赏
  • 举报
回复
大侠,编译通不过了,idl文件编译没错,像你说的那样写:
[
object,
uuid(E0B6A843-9FBE-4A8F-9EBA-49A9AEF1A849),
dual,
helpstring("ITitan Interface"),
pointer_default(unique)
]
interface ITitan : IDispatch
{
[id(1), helpstring("method adGetAdditiveDumpTotal")] HRESULT adGetAdditiveDumpTotal();
[id(2), helpstring("method vv")] HRESULT vv([in] long dr, [in] SAFEARRAY(char) aa, [in] long chann, [in] SAFEARRAY(byte) cc);
};
//但是编译整个项目时出错,下面是生成的C代码:
public:
STDMETHOD(vv)(/*[in]*/ long dr, /*[in]*/ SAFEARRAY(char) aa, /*[in]*/ long chann, /*[in]*/ SAFEARRAY(byte) cc);
//出错如下:
Compiling...
StdAfx.cpp
Compiling...
dlltitan.cpp
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2146: syntax error : missing ')' before identifier 'aa'
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2146: syntax error : missing ';' before identifier 'aa'
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2501: 'aa' : missing storage-class or type specifiers
e:\zsopc\titanpro\dlltitan\titan.h(45) : warning C4518: 'long ' : storage-class or type specifier(s) unexpected here; ignored
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2501: 'chann' : missing storage-class or type specifiers
e:\zsopc\titanpro\dlltitan\titan.h(45) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2146: syntax error : missing ';' before identifier 'cc'
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2059: syntax error : ')'
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2501: 'cc' : missing storage-class or type specifiers
Titan.cpp
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2146: syntax error : missing ')' before identifier 'aa'
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2146: syntax error : missing ';' before identifier 'aa'
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2501: 'aa' : missing storage-class or type specifiers
e:\zsopc\titanpro\dlltitan\titan.h(45) : warning C4518: 'long ' : storage-class or type specifier(s) unexpected here; ignored
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2501: 'chann' : missing storage-class or type specifiers
e:\zsopc\titanpro\dlltitan\titan.h(45) : warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2146: syntax error : missing ';' before identifier 'cc'
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2059: syntax error : ')'
e:\zsopc\titanpro\dlltitan\titan.h(45) : error C2501: 'cc' : missing storage-class or type specifiers
E:\zsopc\titanpro\dlltitan\Titan.cpp(112) : error C2511: 'vv' : overloaded member function 'long (long)' not found in 'CTitan'
e:\zsopc\titanpro\dlltitan\titan.h(15) : see declaration of 'CTitan'
Generating Code...
Error executing cl.exe.

dlltitan.dll - 15 error(s), 5 warning(s)
masterz 2007-04-22
  • 打赏
  • 举报
回复
lm(long dr, SAFEARRAY(char), long chann, SAFEARRAY(byte));
masterz 2007-04-22
  • 打赏
  • 举报
回复
你的c++函数定义有问题,不能直接从idl拷贝过来的
STDMETHOD(vv)(/*[in]*/ long dr, /*[in]*/ SAFEARRAY* aa, /*[in]*/ long chann, /*[in]*/ SAFEARRAY* cc);

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧