var
ProcessSnapShotHandle: THandle;
ProcessEntry: TProcessEntry32;
ProcessHandle: THandle;
Ret: BOOL;
s: string;
Position: Byte;
ModuleSnapShotHandle: THandle;
ModuleEntry: TModuleEntry32;
begin
//TH32CS_SNAPALL
ProcessSnapShotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if ProcessSnapShotHandle > 0 then
begin
ProcessEntry.dwSize := SizeOf(TProcessEntry32);
Ret:=Process32First(ProcessSnapShotHandle, ProcessEntry);
while Retdo
begin
ModuleSnapShotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessEntry.th32ProcessID);
if ModuleSnapShotHandle > 0 then
begin
ModuleEntry.dwSize:=SizeOf(TModuleEntry32);
Ret:=Module32First(ModuleSnapShotHandle, ModuleEntry);
if Pos('mdiapp.exe',ModuleEntry.szExePath) > 0 then
begin
s := ModuleEntry.szExePath;
FProcessID := ModuleEntry.th32ProcessID;
TerminateProcess(OpenProcess(PROCESS_TERMINATE,False, FProcessID), 0);
CloseHandle(ModuleSnapShotHandle)
end;
Ret:=Process32Next(ProcessSnapShotHandle, ProcessEntry)
end;
end;
CloseHandle(ProcessSnapShotHandle);
end;
s就是全路径名