我在论坛发的第一个问题:注册在Windows 20003上的com+返回不正确的值的问题? ( 积分: 50 )

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;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
676
import
I
I
回复
0
查看
555
import
I
I
回复
0
查看
628
import
I
顶部