How to GetClassName

Any_Name_Does

Member
Jul 13, 2010
143
0
0
Hi,
Can someone please help with the following problem:
I launch an application let's say notepad,exe with CreateProcess and call EnumWindows. within the EnumWindows procedure I call GetWindowThreadProcessId for the hWnd and compare it to the process ID retrieved from CreateProces, if it matches I call GetClassName. But it doesn't work. EnumWindows does not return a process ID identical to the one from CreateProces

Thanks.
 

Noobsa44

Member
Jun 7, 2005
65
0
0
Just looking real quick at my own usage of GetWindowThreadProcessId and I noticed that the process ID has both a return value and a out parameter. Are you using the return value rather than the out parameter? If that is not the issue, could you record the two values and use the command line program "tasklist" to find out if both values are legitimate process Ids?

Here is my method signature for GetWindowThreadProcessId in C#:

[DllImportAttribute("user32.dll", EntryPoint = "GetWindowThreadProcessId")]
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId);
 

Any_Name_Does

Member
Jul 13, 2010
143
0
0
Just looking real quick at my own usage of GetWindowThreadProcessId and I noticed that the process ID has both a return value and a out parameter. Are you using the return value rather than the out parameter? If that is not the issue, could you record the two values and use the command line program "tasklist" to find out if both values are legitimate process Ids?

Here is my method signature for GetWindowThreadProcessId in C#:

[DllImportAttribute("user32.dll", EntryPoint = "GetWindowThreadProcessId")]
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId);

Hi and thanks
Well I just got it working accidentally. what I did was pass the dwThreadId of CreateProcess as lParam to EnumWindows and use the direct return value (eax) of GetWindowThreadProcessId to check against lParam and now it works.
Thanks anyway.