描述:
问题简述:
1.用VB开发一个组件:EBString
//////////////////////EBString.cls///////////////////////
Option Explicit
Option Base 0
Private str_String As String
Private Const EMPTY_STRING As String = ""
'读字符串值
Public Property Get Value() As String
Value = str_String
End Property
'写字符串值
Public Property Let Value(ByVal vNewValue As String)
str_String = vNewValue
End Property
2.用Delphi开发一个组件,接口IMy的Method1的返回值使用了1中开发的EBsstring
///////////////////////////Unit1.pas/////////////////////////
unit Unit1;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows,Dialogs, ActiveX, Classes, ComObj, Project1_TLB, StdVcl, CommonType_TLB;
type
TMy = class(TTypedComObject, IMy)
protected
function Method1: _EBString; stdcall;
{Declare IMy methods here}
end;
implementation
uses ComServ;
function TMy.Method1 : _EBString;
begin
result.Value := '111';
end;
initialization
TTypedComObjectFactory.Create(ComServer, TMy, Class_My,
ciMultiInstance, tmApartment);
end.
3.上面2开发的组件的TMy.Method1在Delphi中成功调用,但是在VB中使用却出现了问题。
Private Sub Form_Load()
'Project1.My 步骤2中用Delphi开发的COM组件类
Dim m As New Project1.My
'CommonType.EBString 步骤1中用VB开发的COM组件类
Dim str As New CommonType.EBString
'此句执行出错
str = m.Method1()
Set m = Nothing
Set str = Nothing
End Sub
出错信息:
"0x41071f00"指令引用的"0x41071f00"内存。该内存不能为"read"。