如何确定当前过程中COM使用的内部HWND? [英] How do I determine the internal HWND used by COM in my current process?
本文介绍了如何确定当前过程中COM使用的内部HWND?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在过程中将消息直接发布到COM所拥有的HWND.如何获取COM在单线程公寓模式下使用的HWND?
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?
推荐答案
尝试一下:
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 );
}
让我知道它是否有效.
这篇关于如何确定当前过程中COM使用的内部HWND?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文