Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetWindowThreadProcessId (urgent, pls help)

Status
Not open for further replies.

jbchurn

Programmer
May 7, 2002
3
MY
Hi Sir,

Why do i keep getting zero for the return value of GetWindowThreadProcessId?
any idea? i can't seem to get the correct value for thread id.

Please help.
Thanks in advance.

hWnd = FindWindow("WindowsApp", "Windows App");
dwPid = GetWindowThreadProcessId(hWnd, NULL);

where dwPid always zero.
 
Maybe,you should check your syntaxe for "FindWindow":

HWND FindWindow(
LPCTSTR lpClassName, // class name
LPCTSTR lpWindowName // window name
);
 
yes, i checked.
actually i create a window with classname "WindowsApp"
and window title as "Windows App" for testing.
i even use Spy++ to confirm the classname and title. they are correct.

i attach my program as below, hope you can help me out.
cos i'm stuck here and cannot proceed.


#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {

HWND hWnd;
LPDWORD dwAA;
hWnd = FindWindow(&quot;WindowsApp&quot;, &quot;Windows App&quot;);
dwThreadId = GetWindowThreadProcessId(hWnd, dwAA);

if (dwThreadId == 0) {
MessageBox(NULL, &quot;dwThreadId is zero&quot;, &quot;result&quot;, MB_OK);
}
return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top