Einzelnen Beitrag anzeigen

Benutzerbild von thule
thule

Registriert seit: 4. Okt 2007
13 Beiträge
 
#14

Re: Pfad der eigenen Anwendung - ohne Application. Param...

  Alt 14. Feb 2008, 15:37
Ich habe mein Problem mit Hilfe des Prozessmanagements gelößt:

Delphi-Quellcode:
uses
  PSAPI, TlHelp32;

function GetProcessExeName(hProcess: THandle): String;
var
  ModuleEntry: TModuleEntry32;
  hModuleEntry: THandle;
  ProcessId: Cardinal;
begin
  if hProcess = INVALID_HANDLE_VALUE then Exit;
  ProcessId := GetWindowThreadProcessId(hProcess);
  hModuleEntry := CreateToolHelp32Snapshot(TH32CS_SNAPMODULE, ProcessId);
  ModuleEntry.dwSize := SizeOf(TModuleEntry32);
  Module32First(hModuleEntry, ModuleEntry);
  Result := MOduleEntry.szExePath;
  CloseHandle(hModuleEntry);
end;

//Bsp:
 EXE_Dir_String := ExtractFilePath(GetProcessExeName(0));
//scheint gut zu functionieren.
Gruß
Open is human
  Mit Zitat antworten Zitat