From: Dansk on

Hi all,

I start a process using ShellExecuteEx and I get the process handle.

I also need the process ID, how can I get it ?

Thanks in advance,
Dansk.
From: Elcaro Nosille on
Dansk schrieb:

> Hi all,
> I start a process using ShellExecuteEx and I get the process handle.
> I also need the process ID, how can I get it ?

processId = GetProcessId( hProcess )
?
From: Dansk on
Good catch, this was an easy one.
(http://msdn2.microsoft.com/en-us/library/ms683215.aspx)

More challenging :
How can I get the process Id from its handle on systems prior to winXP sp1 ?

Thanks in advance,
Dansk.

Elcaro Nosille wrote :
> Dansk schrieb:
>
>> Hi all,
>> I start a process using ShellExecuteEx and I get the process handle.
>> I also need the process ID, how can I get it ?
>
> processId = GetProcessId( hProcess )
> ?
From: Gary Chanson on
Do you really need to use ShellExecuteEx? If you use CreateProcess, it
returns the process ID as one of the elements of lpProcessInformation.

--

- Gary Chanson (Windows SDK MVP)
- Abolish Public Schools



"Dansk" <dansk(a)laouilest.com> wrote in message
news:#boXp9UmHHA.4624(a)TK2MSFTNGP04.phx.gbl...
> Good catch, this was an easy one.
> (http://msdn2.microsoft.com/en-us/library/ms683215.aspx)
>
> More challenging :
> How can I get the process Id from its handle on systems prior to winXP sp1
?
>
> Thanks in advance,
> Dansk.
>
> Elcaro Nosille wrote :
> > Dansk schrieb:
> >
> >> Hi all,
> >> I start a process using ShellExecuteEx and I get the process handle.
> >> I also need the process ID, how can I get it ?
> >
> > processId = GetProcessId( hProcess )
> > ?


From: James Brown on
"Dansk" <dansk(a)laouilest.com> wrote in message
news:%23boXp9UmHHA.4624(a)TK2MSFTNGP04.phx.gbl...
> Good catch, this was an easy one.
> (http://msdn2.microsoft.com/en-us/library/ms683215.aspx)
>
> More challenging :
> How can I get the process Id from its handle on systems prior to winXP sp1
> ?
>
> Thanks in advance,
> Dansk.
>
> Elcaro Nosille wrote :
>> Dansk schrieb:
>>
>>> Hi all,
>>> I start a process using ShellExecuteEx and I get the process handle.
>>> I also need the process ID, how can I get it ?
>>
>> processId = GetProcessId( hProcess )
>> ?
>

On NT-based systems use the ZwQueryInformationProcess native API

see: www.catch22.net/tuts/tips2.asp for an example


--
James Brown
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Tutorials and Sourcecode