Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses ... TlHelp32;
- function GetModuleFileName(pID: DWORD): string;
- var
- hSnapshot: THandle;
- mEntr: tagMODULEENTRY32;
- begin
- result:= 'noname';
- hSnapshot:= CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pID);
- if hSnapshot <> INVALID_HANDLE_VALUE then
- try
- mEntr.dwSize:= SizeOf(mEntr);
- if Module32First(hSnapshot, mEntr) then
- result:= mEntr.szExePath;
- finally
- CloseHandle(hSnapshot)
- end;
- end;
- function ParentProcName: string;
- var
- pID: DWORD;
- hSnapshot: THandle;
- ProcessEntry: TProcessEntry32;
- begin
- result:= 'noname';
- hSnapshot:= CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if hSnapshot <> INVALID_HANDLE_VALUE then
- try
- ProcessEntry.dwSize:= SizeOf(ProcessEntry);
- if Process32First(hSnapshot, ProcessEntry) then begin
- pID:= GetCurrentProcessID;
- repeat
- if ProcessEntry.th32ProcessID = pID then begin
- result:= GetModuleFileName(ProcessEntry.th32ParentProcessID);
- Break;
- end;
- until not Process32Next(hSnapshot, ProcessEntry);
- end;
- finally
- CloseHandle(hSnapshot)
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement