高分求助:接口类型在VC中不能用,在VB和Delphi中可以使用!Why?

floodzhu 2002-01-08 04:20:25
我用Delphi做了一个ActiveX控件,其中有一个方法的返回值是一个自定义接口类型,在VB和Delphi中用都没有问题,但是在VC中就不行,为什么?

如下:
ISpace = MyX.GetSpace();
ISpace.doSomething();
在VC中包装成CSpace了,编译通过,运行时触发异常
...全文
86 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wyzegg 2002-03-01
  • 打赏
  • 举报
回复
在VC使用生成类没有办法识别自定义类型,你可以使用import就可以啦
zych72 2002-03-01
  • 打赏
  • 举报
回复
safecall if the facility of delphi to ease Com programming
zych72 2002-03-01
  • 打赏
  • 举报
回复
above is delphi code,
zych72 2002-02-28
  • 打赏
  • 举报
回复
I have create a Com Object with delphi5, and VB6 can not call its method returning BSTR.

I use safecall
if I define the method
Type library Editor
HRESULT _stdcall getString([out, retval] BSTR strValue )
Interface
getString:WideString;safecall;
Implement
getString:WideString;safecall;
the vb6 class browser will crashed when browse the class

if I define the method
Type library Editor
BSTR _stdcall getString( void );
Interface
getString:WideString;safecall;
Implement
getString:WideString;safecall;
it will invoke a access violation error when i call the method.

what is wrong with me? I will highly appreciate your help. thanks.


fantong 2002-02-28
  • 打赏
  • 举报
回复
what is safecall?
I have not see it before in vc or vb
zych72 2002-02-27
  • 打赏
  • 举报
回复
我的贴子在http://www.csdn.net/expert/topic/545/545140.xml
zych72 2002-02-27
  • 打赏
  • 举报
回复
你能在vb中调用返回自定义接口类型的方法,请帮我一下:

我使用delphi生成了一个测试用的com
TestComParam
有3个方法
getInteger return 1
getString return "String"
getObject return self/this

生成了一个Activex dll Library
在delphi中引入这个dll后使用这三个方法都正常
而在Vb6中引入这个dll后只有getInteger方法正常,其他都导致异常,请高手指点

我测试的源码在 http://www.webstar.com.cn/download/testcom.zip下载
请指点为什么在vb中不能正确使用getString:和getObject方法,如何解决

Poincare 2002-01-14
  • 打赏
  • 举报
回复
call way collision in C++ and Pascal
windindance 2002-01-09
  • 打赏
  • 举报
回复
接口实际就是多重继承。
wyzegg 2002-01-08
  • 打赏
  • 举报
回复
VC里面是使用导入类的确有些问题,不过你可以自己写一个相应的类型,直接来使用

1,649

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 非技术类
社区管理员
  • 非技术类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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