Function TransFileNoForm(IP,File_name:pchar;IPPort:integer) :integer;stdcall;
var
  IdTCPClient:TIdTCPClient;
begin  IdTCPClient:=TIdTCPClient.Create(nil);
  IdTCPClient.Host:=string(IP);
  IdTCPClient.Port:=IPPort;
  Application.ProcessMessages;
  try
    IdTCPClient.Connect();
    try
      //---处理过程
    except
      IdTCPClient.Disconnect;
      IdTCPClient.Destroy;
    end;
  except    result:=0;
  end;
end;上面是Idtcpclient的一个处理dll函数,我现在想分成三个函数,
一、连接函数,二、处理函数,三、断开函数
因为连接后处理的功能有好几个,所以想先连接,然后根据需要调用处理函数,最后断开应该怎样处理才好呢?之间怎么调用呢?给个思路

解决方案 »

  1.   

    var
      IdTCPClient:TIdTCPClient;
    Function Connect(IP:pchar;IPPort:integer) :integer;stdcall;
    begin
      if IdTCPClient = nil then  IdTCPClient:=TIdTCPClient.Create(nil);
      IdTCPClient.Host:=string(IP);
      IdTCPClient.Port:=IPPort;
      try
        IdTCPClient.Connect();
      except
        IdTCPClient.Disconnect;
        IdTCPClient.Destroy;
        result:=0;
      end;
    end;
      

  2.   

    因为这个函数可能不一定在D中调用,可能在其他,如PB,VB里调用,所以变量的话一般想使用pchar和int其他工具也能接受,
    我手上有个用C++做的,它就分成连接,多个特定的处理功能函数,和挂断,因为在某个操作中可能只使用到一个处理或几个处理,所有要分开