{I+=codeWee;}
[C++] Win32: How to Find Window Handle by Process ID and Window Class Name
HWND FindWindowByProcessIdAndClassName(DWORD pid, TCHAR* szWndClassName)
{
	HWND hCurWnd = GetTopWindow(0);
	while (hCurWnd != NULL)
	{
		DWORD cur_pid;
		DWORD dwTheardId = GetWindowThreadProcessId(hCurWnd, &cur_pid);
				
		if (cur_pid == pid)
		{
			if (IsWindowVisible(hCurWnd) != 0)
			{
				TCHAR szClassName[256];
				GetClassName(hCurWnd, szClassName, 256);
				if (_tcscmp(szClassName,szWndClassName)==0)
					return hCurWnd;
			}
		}
		hCurWnd = GetNextWindow(hCurWnd, GW_HWNDNEXT);
	}
	return NULL;
}
HTML | PHP | C++ | DirectX11 | Javascript | C# | HTML5 | ASP | SQL | General | CSS | Oculus Rift | Unity3d | Virtools SDK | Tip | NSIS | PowerShell | node.js | Web API | RTSP | All
Copyright© 2016 CodeWee.com All rights reserved.