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 classif 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.

解决方案 »

  1.   

    很奇怪的问题,COM中应该是必须HRESULT作为返回值的,可是这样做ObjectBrowser会崩溃,这个问题我找找资料。
    返回值使用BSTR可能是VB把返回值当作HRESULT,把你的返回值当成错误值处理了。
      

  2.   

    可是返回WordBool/Viriant_Bool/Boolean值、整型值却是对的。而且所有返回其他类型的方法在ObjectBrowser中都可以正常浏览
      

  3.   

    在delphi5中使用这些com无比正确,怎么在VB中就不行呢?