Chemin Complet du .exe via PID
me voilà un peu embêté...
le code suivant fonctionnne sur Win2k...
le chemin complet de l'executable s'affiche...
"c:\temp\test1\test.exe"
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
(* declaration in C PSAPI.DLL
DWORD GetModuleFileNameEx( HANDLE hProcess, // handle to the process
HMODULE hModule, // handle to the module
LPTSTR lpFilename, // buffer that receives the path
DWORD nSize // size of the buffer);
*)
function GetModuleFileNameEx(hProcess : THandle; hModule : THandle;
lpFileName : pchar;
nSize : DWORD): DWORD; stdcall;
implementation
{$R *.DFM}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
hProcess:DWORD;
FileNamePath: array[0..512] of Char;
begin
hProcess:=OpenProcess( PROCESS_QUERY_INFORMATION OR PROCESS_VM_READ,
FALSE,
GetCurrentProcessId);
GetModuleFileNameEx(hProcess,0,FileNamePath,sizeof(FileNamePath));
RichEdit1.lines.Add(FileNamePath);
CloseHandle(hprocess);
end;
//*** External Function from PSAPI.DLL ****
function GetModuleFileNameEx; external 'psapi.dll' index 13; |
lorsque je l'execute sur XP...
j'ai juste le nom de l'executable... et je perds le path...
"test.exe"
8O
La question c'est comment avec XP je peux trouver le chemin complet d'un
exe via son ProcessID?