R
root_zh
Unregistered / Unconfirmed
GUEST, unregistred user!
开发环境:Delphi 7
做了一个COM+的类库,在本机上测试返回数据没有问题,注册到Windows2003上返回数据不正确,COM+类库如下:
unit Uint_Server;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, ActiveX, Classes, ComObj, Server_TLB, StdVcl;
type
TTServer = class(TTypedComObject, ITServer)
protected
function GetInfo: SYSINT;
stdcall;
function GetString(out p_strName: OleVariant): HResult;
stdcall;
end;
implementation
uses ComServ;
function TTServer.GetInfo: SYSINT;stdcall;
begin
Result := 12345;
end;
function TTServer.GetString(out p_strName: OleVariant): HResult;
begin
p_strName := 'Return String. ';
Result := 0;
end;
initialization
TTypedComObjectFactory.Create(ComServer, TTServer, Class_TServer,
ciMultiInstance, tmApartment);
end.
客户端调用:
procedure TForm1.Button1Click(Sender: TObject);
var
server : ITServer;
a : Integer;
t : OleVariant;
s : string;
//str : WideString;
begin
server := CoTServer.CreateRemote( '192.168.0.2 ' );
a := Server.GetInfo;
ShowMessage( IntToStr( a ) );//没有返回12345,而是262658
a := server.GetString( t );
//返回空字符串
s := t;
ShowMessage( s );
end;
做了一个COM+的类库,在本机上测试返回数据没有问题,注册到Windows2003上返回数据不正确,COM+类库如下:
unit Uint_Server;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, ActiveX, Classes, ComObj, Server_TLB, StdVcl;
type
TTServer = class(TTypedComObject, ITServer)
protected
function GetInfo: SYSINT;
stdcall;
function GetString(out p_strName: OleVariant): HResult;
stdcall;
end;
implementation
uses ComServ;
function TTServer.GetInfo: SYSINT;stdcall;
begin
Result := 12345;
end;
function TTServer.GetString(out p_strName: OleVariant): HResult;
begin
p_strName := 'Return String. ';
Result := 0;
end;
initialization
TTypedComObjectFactory.Create(ComServer, TTServer, Class_TServer,
ciMultiInstance, tmApartment);
end.
客户端调用:
procedure TForm1.Button1Click(Sender: TObject);
var
server : ITServer;
a : Integer;
t : OleVariant;
s : string;
//str : WideString;
begin
server := CoTServer.CreateRemote( '192.168.0.2 ' );
a := Server.GetInfo;
ShowMessage( IntToStr( a ) );//没有返回12345,而是262658
a := server.GetString( t );
//返回空字符串
s := t;
ShowMessage( s );
end;