Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I get the process ids of the applications or windows opened via windows service and log them, but I noticed that, for example, the tabs opened in chrome always give the same PID, and at the same time, it always gives the pid of "explorer.exe" in the window that opens while the file is being copied. Do I have a chance to get real pids in such processes?

What I have tried:

        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern int GetWindowThreadProcessId(HandleRef handle, out int processId);

public static int GetRealProcessID(IntPtr WindowHandle)
        {
            int parentProcessId;

            GetWindowThreadProcessId(new HandleRef(null, WindowHandle), out parentProcessId);

            return parentProcessId;
        }
Posted
Updated 23-Oct-22 22:51pm
v2

1 solution

In previous versions of IE you could change a registry setting, but it was unreliable.

For IE11, have a look at the solution here - https://superuser.com/questions/1130849/internet-explorer-11-process-per-tab[^]

You should also take note of the fact that IE was "retired" in June of this year. If you use Chrome or Edge you will get unique PIDs
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900