params = “protocol=TCP,ipaddress=192.168.12.154,port=4370,timeout=4000,passwd=”
self.commpro = windll.LoadLibrary("plcommpro.dll")
con_str = create_string_buffer(params)
self.hcommpro = self.commpro.Connect(con_str)这段怎么转为dephi  特别是 create_string_buffer 这个函数、con_str 类型delphi:function Connect(Parameters: PChar): THandle; cdecl; external 'plcommpro.dll';DLLHandle, ControlHandle: THandle;
Params :string;  Params := 'protocol=TCP,ipaddress=192.168.1.222,port=4370,timeout=4000,passwd=';
  ControlHandle := Connect(Params);  //句柄返回都是0大神~ 帮忙翻译下!!delphibufferpython

解决方案 »

  1.   

    试下将Params定义为PChar,并且把cdecl改为stdcallfunction Connect(Parameters: PChar): THandle; stdcall; external 'plcommpro.dll';procedure TForm2.Button1Click(Sender: TObject);
    var
      Params: PChar;
      DLLHandle, ControlHandle: THandle;
    begin
      Params := 'protocol=TCP,ipaddress=192.168.1.222,port=4370,timeout=4000,passwd=';
      ControlHandle := Connect(Params);
    end;