HWND GetWindowHandleByPID(DWORD dwProcessID)
{
HWND h = GetTopWindow( 0 );
while ( h )
{
DWORD pid = 0 ;
DWORD dwTheardId = GetWindowThreadProcessId( h, & pid);
if (dwTheardId != 0 )
{
if ( pid == dwProcessID /* your process id */ )
{
// here h is the handle to the window
return h;
}
}
h = GetNextWindow( h , GW_HWNDNEXT);
}
return NULL;
}
{
HWND h = GetTopWindow( 0 );
while ( h )
{
DWORD pid = 0 ;
DWORD dwTheardId = GetWindowThreadProcessId( h, & pid);
if (dwTheardId != 0 )
{
if ( pid == dwProcessID /* your process id */ )
{
// here h is the handle to the window
return h;
}
}
h = GetNextWindow( h , GW_HWNDNEXT);
}
return NULL;
}