Danke für eure Hilfe, es Funktioniert jetzt.
Delphi-Quellcode:
iThreadID:=FWorker.ThreadID;
hThread:=OpenThread(THREAD_TERMINATE or THREAD_QUERY_INFORMATION ,false,iThreadID);
if hThread<>0 then
try
System.SetLastError(ERROR_SUCCESS);
iThreadExitCode:=0;
if not GetExitCodeThread(hThread,iThreadExitCode) then
sMsg:=SysErrorMessage(GetLastError);
System.SetLastError(ERROR_SUCCESS);
bOK:=TerminateThread(hThread,iThreadExitCode);
if bOK then
sMsg:='OK'
else
begin
sMsg:=SysErrorMessage(GetLastError);
end;
finally
CloseHandle(hThread);
end;