procedure TForm1.Button1Click(Sender: TObject);
var
lLoop,c : word;
err, getNum : KMErrorCode;
NumDevices : Word;
erg : string;
nBuff,ipBuff,SerStrBuff : array of Pchar;
DipArrayBuff : Array of PUint16;
name : Array[0..MAX_TCP_NM_LENGTH] of pChar;
ip: Array[0..MAX_TCP_IP_LENGTH] of pChar;
ser: Array[0..MAX_TCP_SN_LENGTH] of pChar;
sName, sIp, sSerial : String;
begin
err := KMInitialize;
Memo1.Lines.Append('Wait....');
NumDevices :=0;
KMTCPRefreshDevices();
getNum := KMTCPGetNumDevices(NumDevices);
SetLength(nBuff, NumDevices);
SetLength(ipBuff, NumDevices);
SetLength(serStrBuff, NumDevices);
SetLength(DipArrayBuff, NumDevices);
for lLoop := 0 to NumDevices-1 do
begin
for c:= 0 to MAX_TCP_NM_LENGTH do name[c] := new(pChar);
nBuff[lLoop] := name[0];
for c:= 0 to MAX_TCP_IP_LENGTH do
ip[c] := new(pChar);
ipBuff[lLoop] :=
ip[0];
for c:= 0 to MAX_TCP_SN_LENGTH do ser[c] := new(pChar);
serStrBuff[lLoop] := ser[0];
DipArrayBuff[lLoop] := new(PUint16);
end;
if getNum = 0 then
begin
err := KMTCPGetDeviceInformation(@nBuff[0], @ipBuff[0], @serStrBuff[0], DipArrayBuff[0], NumDevices);
end;
if err = 0 then
begin
memo1.Lines.Append(' Controllers Found '+IntToStr(NumDevices));
for c:= 0 to NumDevices-1 do
begin
Memo1.Lines.Append('Name : '+nBuff[c]);
Memo1.Lines.Append('
Ip-Addr : '+ipBuff[c]);
Memo1.Lines.Append('Serial : '+serStrBuff[c]);
Memo1.Lines.Append('Dip Settings : '+IntToStr(DipArrayBuff[c]^));
Memo1.Lines.Append(StringOfChar('-', 60));
end;
end;
Memo1.Lines.Append('finished');
end;