//结束进程<br>procedure Tfrmmain.EndProcess(AFileName: string);<br>const<br> PROCESS_TERMINATE = $0001;<br>var<br> ContinueLoop: BOOL;<br> FSnapShotHandle: THandle;<br> FProcessEntry32: TProcessEntry32;<br>begin<br> FSnapShotHandle := CreateToolhelp32SnapShot(TH32CS_SNAPPROCESS, 0);<br> FProcessEntry32.dwSize := SizeOf(FProcessEntry32);<br> ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);<br> while integer(ContinueLoop) <> 0 do<br> begin<br> if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =UpperCase(AFileName))<br> or (UpperCase(FProcessEntry32.szExeFile ) =UpperCase(AFileName))) then<br> TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),<br> FProcessEntry32.th32ProcessID), 0);<br> ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);<br> end;<br>end;