大侠们,ATL里这样用,竟然不行?????

explosun 2003-10-16 10:25:39
声明[id(13), helpstring("method test")] HRESULT test(BSTR *str);
test(BSTR *str)
{
_bstr_t a;
a="hello";
*str=a.copy();
return S_OK;
}
客户端VB
Form.load()
Dim a As New Org
Dim str As String
str = "hi"
a.test (str)
MsgBox str
我想我这样用应该没错吧,可是还是不能把传入的变量改为HELLO,请问这是怎么回事????
...全文
31 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
XXandOO 2003-10-18
  • 打赏
  • 举报
回复
除了上边说的,
*str=a.copy();---[out]参数不能这样写

最好这样写
CComBSTR combstr;
combstr = Attach(a);
str = SysAllocString(combstr);
warmchang 2003-10-18
  • 打赏
  • 举报
回复
[in, out]!
Darkay_Lee 2003-10-18
  • 打赏
  • 举报
回复
就是这个[out]
shudingbo 2003-10-18
  • 打赏
  • 举报
回复
同上!
Analyst 2003-10-17
  • 打赏
  • 举报
回复
声明[id(13), helpstring("method test")] HRESULT test([in, out]BSTR *str);
DragonFly-9 2003-10-17
  • 打赏
  • 举报
回复
声明[id(13), helpstring("method test")] HRESULT test([out,retval]BSTR *str);
test(BSTR *str)
{
*str=L"hello";
return S_OK;
}
honghaozi 2003-10-16
  • 打赏
  • 举报
回复
在定义前加上[in,out]
explosun 2003-10-16
  • 打赏
  • 举报
回复
为什么没有回答我的问题,我自己UP

3,245

社区成员

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

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