![]() |
prozess-handle --> dateiname
wie kann ich durch den prozess-handle den dateinamen des prozesses herausbekommen?
|
Re: prozess-handle --> dateiname
kleiner Auszug aus nem Source
Delphi-Quellcode:
uses .., tlhelp32, .., ..;
procedure TProcessList.GetHandleInfo(WinHandle: HWND; var akttask: TTask); var dwActiveProcessId,hModuleSnap:DWORD;snap:THandle;pe32,pe2:TPROCESSENTRY32;me32:TMODULEENTRY32; Begin GetWindowThreadProcessId(WinHandle, @dwActiveProcessId); Snap := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0); if Process32First(Snap, pe32) = true then begin if pe32.th32ProcessID = dwActiveProcessId then pe2 := pe32; while Process32Next(Snap, pe32) = true do if pe32.th32ProcessID = dwActiveProcessId then pe2 := pe32; end; akttask.ExeFile := pe2.szExeFile; [...] |
Re: prozess-handle --> dateiname
Zitat:
Ab Windows XP gäbe es diese Möglichkeit... (hat den Vorteil, dass man 'nur' PROCESS_QUERY_INFORMATION benötigt - statt PROCESS_QUERY_INFORMATION und PROCESS_VM_READ für GetModuleFilenameEx)
Delphi-Quellcode:
...wobei das Ergebnis möglicherweise nicht ganz Deinen Erwartungen entsprechen wird (zum Beispiel: '\Device\HarddiskVolume6\borland\Delphi6\Projects\ Project1.exe')
// requires PROCESS_QUERY_INFORMATION (and Windows XP)
function GetProcessImageFileName(Process: THandle): string; type TFNGetProcessImageFileNameA = function(Process: THandle; ImageFileName: LPSTR; Size: DWORD): DWORD; stdcall; const Size = MAX_PATH; var PsApiModule: HMODULE; GetProcessImageFileNameA: TFNGetProcessImageFileNameA; begin Result := ''; PsApiModule := LoadLibrary('psapi.dll'); if (PsApiModule <> 0) then try GetProcessImageFileNameA := TFNGetProcessImageFileNameA( GetProcAddress(PsApiModule, 'GetProcessImageFileNameA')); if not Assigned(GetProcessImageFileNameA) then SetLastError(ERROR_CALL_NOT_IMPLEMENTED) else begin SetLength(Result, Size + 1); SetLength(Result, GetProcessImageFileNameA(Process, PChar(Result), Size)); end; finally FreeLibrary(PsApiModule); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:34 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz