已知DLL的HMODULE,如何获取加载该DLL的应用程序的主窗口句柄HWND?主应用程序可能不同,但肯定都有窗口。
解决方案 »
- 关于MSComm控件的疑问,求解
- 无模式对话框为什么不能在app类的InitInstance()中写
- 请大侠们帮忙!! 如何只查找指定的显示窗口而一旦把对话框隐藏后就找不到了??
- 一个bug,请高手指教
- 使用terminateprocess进程停止遇到的问题
- listview 的行高问题
- 如何设置cedit中输入的字母是大写,还是让它只能输入0-F之间的数据呢
- XP下创建系统钩子,却只能监视一个进程。
- 我应该放弃VC吗?好迷茫啊,请各位提一点意见!帮UP的有分!
- 请教如何在对话框中响应WM_KEYDOWN消息.
- 无条件散分!!!!!!!!!!!!!!!!!
- 定时用SetDlgItemText()更新edit导致耗费内存而不能拷屏
CWnd* AfxGetMainWnd( );Return ValueIf the server has an object that is in-place active inside a container, and this container is active, this function returns a pointer to the frame window object that contains the in-place active document. If there is no object that is in-place active within a container, or your application is not an OLE server, this function simply returns the m_pMainWnd of your application object.If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call.ResIf your application is an OLE server, call this function to retrieve a pointer to the active main window of the application instead of directly referring to the m_pMainWnd member of the application object.If your application is not an OLE server, then calling this function is equivalent to directly referring to the m_pMainWnd member of your application object.See Also CWinThread::m_pMainWnd
http://msdn.microsoft.com/msdnmag/issues/02/07/CQA/
Good Luck!!
EnumProcess或者FindWindow的方式是可行的,但
1. 麻烦,是否有简单的方法
2. 宿主程序可能是多种。
回 syy64(太平洋) :
宿主程序并不是自己开发的,比如MediaPlayer之类的