Grinder ha escrito:
> Does anyone know how to get the process identifier if the
> process handle is known?
AFAIK you can do the reverse, i.e. get a process handle if you know the
process id, but I haven't seen anything in the SDK to do what you want.
Maybe it's a Windows limitation? However you can get it by other ways:
for example, if you know the window handle of a window property of that
process, you can get the process name, and then you can get the process
id using that process name... But you will need the free JCL library
from www.delphi-jedi.org.
regards, Pi
> Does anyone know how to get the process identifier if the
> process handle is known?
{NT only}
var
hProcess, hThread: THandle;
pGetCurrentProcessID: Pointer;
rtid, pid: DWord;
..
pGetCurrentProcessID := GetProcAddress( GetModuleHandle('kernel32.dll'),
'GetCurrentProcessId');
Win32Check(pGetCurrentProcessID <> nil);
hThread:= CreateRemoteThread ( hProcess,
nil,
0,
pGetCurrentProcessID,
nil,
0,
rtid);
Win32Check(hThread <> 0);
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, pid);
CloseHandle(hThread);
Caption := IntToStr(pid); // result
--
Regards, LVT.
What do you mean by "process name"?
"Pi" <parn...@gmx.net> wrote in message
news:3BFF0F06...@gmx.net...
> What I'm after is a trim way to use ShellExecuteEx and
> EnumWindows--I want to be able to tell if the window belongs to
> the process I hold the handle to.
FindExecutable {uses ShellApi}
CreateProcess
WaitForInputIdle
EnumWindows & GetWindowThreadProcessId
--
Regards, LVT.
"Leonid Troyanovsky" <lv...@eco-pro.ru> wrote in message
news:3C00DC5C...@eco-pro.ru...