Get PID from hProcess through CreateRemoteThread? 
Author Message
 Get PID from hProcess through CreateRemoteThread?

I have an hProcess returned from ShellExecuteEx. I need the PID instead.
Apparently its very difficult to get. I understand I can use
CreateRemoteThread in some way but don't see any examples anywhere.

Can someone please tell me how to use CreateRemoteThread to call
GetCurrentProcessId and end up with a PID for hProcess?

This only has to work on Win2K and higher. Any other suggestions would be
great. I wish to stay away from CreateProcess, which is why I'm using
ShellExecuteEx.

Thanks.



Sun, 03 Oct 2004 14:06:38 GMT  
 Get PID from hProcess through CreateRemoteThread?
I have an hProcess returned from ShellExecuteEx. I need the PID instead.
Apparently its very difficult to get. I understand I can use
CreateRemoteThread in some way but don't see any examples anywhere.

Can someone please tell me how to use CreateRemoteThread to call
GetCurrentProcessId and end up with a PID for hProcess?

This only has to work on Win2K and higher. Any other suggestions would be
great. I wish to stay away from CreateProcess, which is why I'm using
ShellExecuteEx.

Thanks.



Sun, 03 Oct 2004 21:56:08 GMT  
 Get PID from hProcess through CreateRemoteThread?


Quote:
>I have an hProcess returned from ShellExecuteEx. I need the PID instead.
>Apparently its very difficult to get. I understand I can use
>CreateRemoteThread in some way but don't see any examples anywhere.
>Can someone please tell me how to use CreateRemoteThread to call
>GetCurrentProcessId and end up with a PID for hProcess?

You can use the Toolhelp functions CreateToolHelp32Snapshot followed
by Process32First and Process32next to loop through the processes..  
The returned structure contains a PID, IIRC.  
Have a search of this group at google, there have been some expmales
posted in the past.

Actually if C doesn't scare you this MSDN article may help.
Article ID: Q175030

Regards, Frank



Mon, 04 Oct 2004 07:23:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getting hWnd when you know hProcess

2. Getting hWnd from hProcess (more info)

3. Getting hWnd from hProcess

4. How to tie the dllhost.exe PID to COM+ Application PID programmatically

5. Getting the PID / Task ID of running program

6. Getting a PID, VB 4.0 32-bit, NT, Shell function

7. Getting programs PID

8. Getting PID to Kill Job

9. Getting programs PID

10. hProcess coming back from ShellExecuteEx is always 0

11. hProcess restituito da ShellExecuteEx sempre a 0

12. Process Handle hProcess problem

 

 
Powered by phpBB® Forum Software