views:

86

answers:

2

Hello,

I'm stuck with the process model of IE8, where a GetWindowThreadProcessId() for my MFC embedded window will give me a child IE PID, as the GetWindowThreadProcessId() for my container page will give me the root IE PID.

Which is bad, as I want to filter my container out, while enumerating windows.

So I'm looking for a way to get the PID of the parent of a given process, so as to get, from my MFC app, the root IE PID.

Sysinternals' ProcessExplorer knows how to do that, displaying processes in treeview, so I'm sure there's a way to achieve that.

+1  A: 

Have you seen this codeproject article or this codeguru article?

I think the better method is in the codeguru article.

Basically you want the "ULONG InheritedFromUniqueProcessId" member of PROCESS_BASIC_INFORMATION. See NtQueryInformationProcess and this page.

Brian R. Bondy
Personally I prefer NtQueryInformationProcess, and link against ntdll.dll statically :)
Anton Tykhyy
@Anton Tykhyy: agree
Brian R. Bondy
I saw the codeproject method in MSDN and was hoping for a less complicated solution. I'll give a try to NtQueryInformationProcess, thanks for your help.
Vinzz
A: 

use ToolHelp32 functions http://support.microsoft.com/kb/192986 and sort their as tree.

But if you have embeded window, maybe your code in IE process? what type of embeding are you use, ocx or dll?

bb
ocx, sir. I'll try the NtQueryInformationProcess way, thanks for your answer.
Vinzz