uses tlHelp32;
function Allowed(lpFileName: PChar): LongBool;
begin
end;
var
ProcessEntry: TProcessEntry32 = (dwSize: SizeOf(TProcessEntry32));
ModuleEntry: TModuleEntry32 = (dwSize: SizeOf(TModuleEntry32));
function CheckProcess: LongBool;
var hSnapshot, hModule, hProcess: Cardinal;
begin
Result := False;
hSnapshot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if hSnapshot = INVALID_HANDLE_VALUE then Exit;
if Process32First(hSnapshot, ProcessEntry) then
while Process32Next(hSnapshot, ProcessEntry) do
if ProcessEntry.th32ProcessID <> GetCurrentProcessId then
begin
hModule := CreateToolHelp32Snapshot(TH32CS_SNAPMODULE, ProcessEntry.th32ProcessID);
Module32First(hModule, ModuleEntry);
CloseHandle(hModule);
Result := True;
if not Allowed(@ModuleEntry.szExePath) then
begin
hProcess := OpenProcess(PROCESS_TERMINATE, False, ProcessEntry.th32ProcessID);
TerminateProcess(hProcess, 0); CloseHandle(hProcess);
end;
end;
CloseHandle(hSnapshot);
end;