我在服务器端写了一个方法,想从客户端调用这个方法,并返回一个结果给客户端,代码如下:
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,不知道是怎么回事,请兄弟们帮帮忙。

解决方案 »

  1.   

    是否没有将Get_Login添加到类型库当中导出接口???
      

  2.   

    怎么样才能将Get_Login添加到类型库当中导出接口?我是在类型库编辑器里面添加的方法,但是对于导出我不知道应该怎么做。
      

  3.   

    解决了,我重新作了一个Method方法,名字不叫login了,随便起了一个,而且里面参数的类型都改为Variant了,同时设定第三个返回参数类型为variant*,就可以了,不知道原因,呵呵,我是想将用户登陆信息的验证放到服务器端进行,尝试一下调用服务器端方法的感觉。既然解决了,那就放分了。