I want to Post messages directly to the HWND that's owned by COM in my process. How do I get the HWND that COM is using in single-threaded-apartment mode?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Try this:
HWND prevWindow = NULL;
HWND hwnd;
for ( ;; )
{
hwnd = FindWindowEx( HWND_MESSAGE, prevWindow, L"OleMainThreadWndClass", NULL );
if ( !hwnd )
break;
if ( GetWindowThreadProcessId( hwnd, NULL ) == GetCurrentThreadId() )
break;
prevWindow = hwnd;
WCHAR className[255];
*className = 0;
::GetClassName( hwnd, className, 255 );
}
Let me know if it works.