M
microkong
Unregistered / Unconfirmed
GUEST, unregistred user!
VC生成的idl定义:
[id(1), helpstring("method DoSome"] HRESULT DoSome([out]LPSTR returnvalue, [out]int* returncode);
VC的CProxy_IServEvents类(用ATL生成)里定义:
HRESULT CProxy_IServEvents::Fire_DoSome(LPSTR returnvalue, INT * returncode)
{
....
//参数定义:
pvars[1].vt = VT_BYREF | VT_LPSTR;
pvars[1].pcVal = returnvalue;
pvars[0].vt = VT_BYREF | VT_INT;
pvars[0].pintVal = returncode;
....
}
用VC赋值没有问题:
void __stdcall CEventSink:oSome(LPSTR returnvalue, INT * returncode)
{
strcpy(returnvalue, "123"
*returncode = 1;
}
但在delphi里赋值就不行
TLB里的定义:
TServDoSome = procedure(Sender: TObject;
var returnvalue: {??PChar}OleVariant;
var returncode: OleVariant) of object;
procedure TServ.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
case DispID of
-1: Exit; // DISPID_UNKNOWN
1: if Assigned(FOnDoSome) then
FOnDoSome(Self, Params[0] {out SYSINT}, Params[1] { ??PChar OleVariant});
end; {case DispID}
end;
自己程序里事件的赋值操作:
procedure TForm1.Serv1DoSome(Sender: TObject; var returnvalue, returncode: OleVariant);
begin
returncode := 1;
returnvalue := '123';
end;
COM组件里的值没有改变。
[id(1), helpstring("method DoSome"] HRESULT DoSome([out]LPSTR returnvalue, [out]int* returncode);
VC的CProxy_IServEvents类(用ATL生成)里定义:
HRESULT CProxy_IServEvents::Fire_DoSome(LPSTR returnvalue, INT * returncode)
{
....
//参数定义:
pvars[1].vt = VT_BYREF | VT_LPSTR;
pvars[1].pcVal = returnvalue;
pvars[0].vt = VT_BYREF | VT_INT;
pvars[0].pintVal = returncode;
....
}
用VC赋值没有问题:
void __stdcall CEventSink:oSome(LPSTR returnvalue, INT * returncode)
{
strcpy(returnvalue, "123"
*returncode = 1;
}
但在delphi里赋值就不行
TLB里的定义:
TServDoSome = procedure(Sender: TObject;
var returnvalue: {??PChar}OleVariant;
var returncode: OleVariant) of object;
procedure TServ.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
case DispID of
-1: Exit; // DISPID_UNKNOWN
1: if Assigned(FOnDoSome) then
FOnDoSome(Self, Params[0] {out SYSINT}, Params[1] { ??PChar OleVariant});
end; {case DispID}
end;
自己程序里事件的赋值操作:
procedure TForm1.Serv1DoSome(Sender: TObject; var returnvalue, returncode: OleVariant);
begin
returncode := 1;
returnvalue := '123';
end;
COM组件里的值没有改变。