此款源码功能不少,大家下载后要慢慢的体验其中的代码。下图是编译好的程序:
分析其中的结束进程函数,原型:
以下是代码片段:
procedure TForm1.EndProcess(AFileName: string); const PROCESS_TERMINATE = $0001; var ContinueLoop: BOOL; FSnapShotHandle: THandle; FProcessEntry32: TProcessEntry32; KillHandle: THandle;//用于杀死进程 begin FSnapShotHandle := CreateToolhelp32SnapShot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := SizeOf(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32); while integer(ContinueLoop) <> 0 do begin if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile))=UpperCase(AFileName)) or (UpperCase(FProcessEntry32.szExeFile )=UpperCase(AFileName))) then begin KillHandle := OpenProcess(PROCESS_TERMINATE, False, FProcessEntry32.th32ProcessID); TerminateProcess(KillHandle, 0);//强制关闭进程 CloseHandle(KillHandle); exit; end; ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); end; end; |
源码下载:http://www.txwb.com/Soft/jclx/201002/1449.html