Hi,
I use an external C-library; but apperently there's something wrong in the type-conversion. Could anyone help?
This is the C-function:
LONG WINAPI MBTConnect(
IN LPCTSTR szHostAddress, // TCP/IP address of device
IN WORD port, // TCP port in device for communication
IN BOOL useTCPorUDP, // TRUE - TCP; FALSE - UDP
IN DWORD requestTimeout, // maximal time for managing an I/O request (ms)
OUT HANDLE *hSocket // handle of the connected socket
);
This is the code that I use:
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComCtrls, ShellApi;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{private declarations}
Chandle_: Thandle;
Ret:longword;
public
{ public declarations }
const
ipadr_: pchar = '192.168.1.222';
port_:integer = 502;
UseTCP_:boolean= FALSE;
ReqTime_:longword = 1000;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
function MBTInit():integer;cdecl;external 'MBT.dll';
procedure MBTConnect(adr:pchar;port:boolean;UseTCP:longword;ReqTime:longword;Chandle:Thandle);cdecl;external 'MBT.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
if MBTInit() = 0 then
begin
MBTConnect(ipadr_,port_,UseTCP_,ReqTime_,Chandle_);
end;
end;
The compiler links it alle together but I get always an 'External SIGSEGV' error when running the program
thx,
T