[难!]已知进程名称!如何得到该进程的路径!欢迎讨论!随便讲!嘿嘿!(10分)

  • 主题发起人 主题发起人 tigerhacker
  • 开始时间 开始时间
T

tigerhacker

Unregistered / Unconfirmed
GUEST, unregistred user!
[难!]已知进程名称!如何得到该进程的路径!欢迎讨论!随便讲!嘿嘿!
注意:进程非系统进程!
 
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就是全路径名
 
好的!谢谢了!好好研究下!嘿嘿!揭帖!
 
后退
顶部