我在服务器端写了一个方法,想从客户端调用这个方法,并返回一个结果给客户端,代码如下:
server:
type
TS_RM = class(TRemoteDataModule, IS_RM)
……
private
{ Private declarations }
……
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
function Get_login(const passwd, name: WideString): OleVariant; safecall;
public
{ Public declarations }
end;implementation
……
function TS_RM.Get_login(const passwd, name: WideString): OleVariant;
begin
with ADOQ_login do
begin
Close;
SQL.Clear;
SQL.Add('select * from logintable where user_name='''+name+'''');
Open;
if SameText(Fields[1].AsString,passwd) then
result:=1
else
result:=0;
end;
end;Client:
procedure TForm1.SocketConnection1AfterConnect(Sender: TObject);
var
aa:OLEVariant;
begin
aa:=Socketconnection1.AppServer.Get_login(edit1.Text,edit2.Text);
if (aa=1) then
showmessage('1')
else
showmessage('0');
end;procedure TForm1.Button1Click(Sender: TObject);
begin
socketconnection1.Connected:=true;
end;
每次运行客户端,点击按钮以后就出现错误提示:Method 'Get_login' not Supported by automation object,不知道是怎么回事,请兄弟们帮帮忙。
server:
type
TS_RM = class(TRemoteDataModule, IS_RM)
……
private
{ Private declarations }
……
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
function Get_login(const passwd, name: WideString): OleVariant; safecall;
public
{ Public declarations }
end;implementation
……
function TS_RM.Get_login(const passwd, name: WideString): OleVariant;
begin
with ADOQ_login do
begin
Close;
SQL.Clear;
SQL.Add('select * from logintable where user_name='''+name+'''');
Open;
if SameText(Fields[1].AsString,passwd) then
result:=1
else
result:=0;
end;
end;Client:
procedure TForm1.SocketConnection1AfterConnect(Sender: TObject);
var
aa:OLEVariant;
begin
aa:=Socketconnection1.AppServer.Get_login(edit1.Text,edit2.Text);
if (aa=1) then
showmessage('1')
else
showmessage('0');
end;procedure TForm1.Button1Click(Sender: TObject);
begin
socketconnection1.Connected:=true;
end;
每次运行客户端,点击按钮以后就出现错误提示:Method 'Get_login' not Supported by automation object,不知道是怎么回事,请兄弟们帮帮忙。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货