Registriert seit: 13. Jun 2004
Ort: Gießen
187 Beiträge
Delphi 2006 Professional
|
Re: Frage zu Threads und Rückgabewerten/Parametern
29. Jun 2006, 12:20
Also in etwa so:
Delphi-Quellcode:
type
TPing = record
IP: String;
Ping: Integer;
end;
...
procedure test;
var
Test: TPing;
PTest: ^TPing;
hThread: THandle;
ThreadID: Cardinal;
begin
PTest := @Test;
hThread := BeginThread( nil, 0, @Thread, PTest, 0, ThreadID);
repeat
GetExitCodeThread(hThread, ExitCode);
Application.ProcessMessages;
sleep(1);
until (ExitCode = 0);
ShowMessage(IntToStr(Test.Ping));
end;
und im Thread dann
Delphi-Quellcode:
function Thread(p: Pointer): Integer;
begin
try
Ping := u_retPing.ICMPPingRTT(u_retPing.DNSNameToIp(p^.IP), Cardinal(1000));
result := 0;
except
on e: exception do
result := 0;
end;
end;
Richtig so?
Stefan Hueg
|
|
Zitat
|