这个是Delphi封装的2个函数
function RegServer(SName:pchar;Port:integer):integer
function Connect(SName:pchar;Port:integer):integer
PB中调用DLL
public function int RegServer(string sName, int port) library "FlagClient0.dll"
public function int ConnectConn(string sName, int port) library "FlagClient0.dll" alias for
"Connect"
点击按钮触发
int result = RegServer("192.168.100.135",9999)
int result2 = ConnectConn("192.168.100.135",9999)
messageBox("1",result2)
messageBox应该返回“0” 现在返回的是“1” 是不是传的参数的问题呀!
------解决方案--------------------
public function int RegServer(string sName, int port) library "FlagClient0.dll"
public function int ConnectConn(string sName, int port) library "FlagClient0.dll" alias for
应该声明为
public function long RegServer(string sName, long port) library "FlagClient0.dll"
public function long ConnectConn(string sName, long port) library "FlagClient0.dll" alias for
Delphi中的integer和pb的long是对应的
------解决方案--------------------
如果是pb10以上版本,注意修改为以下
public function long RegServer(string sName, long port) library "FlagClient0.dll" alias for "RegServer;Ansi"
public function long ConnectConn(string sName, long port) library "FlagClient0.dll" alias for "Connect;Ansi"