我是用dll插入到目标进程想创建一个窗口 但是一旦创建窗口目标进程就未响应
好像在在afxbeginthread这里 。。 我是想创建一个飞模态对话框 
部分代码如下: BOOL CHOOKApp::InitInstance() 
{
// TODO: Add your specialized code here and/or call the base class
m_Thread = new CWinThreadEx ;
m_Thread = (CWinThreadEx *)AfxBeginThread(RUNTIME_CLASS(CWinThreadEx)); 
        //这里启动创建对话框的线程 好像这里一旦启动线程目标进程就卡死掉了
         
return CWinApp::InitInstance();
}BOOL CWinThreadEx::InitInstance()
{
// TODO:  perform and per-thread initialization here
AfxMessageBox("aa"); //这里的信息并没有弹出来...
m_Dlg->Create(IDD_DIALOG1,NULL); /这里创建窗口
m_Dlg->ShowWindow(SW_SHOW);
return TRUE;
}int CWinThreadEx::ExitInstance()
{
// TODO:  perform any per-thread cleanup here
m_Dlg->SendMessage(WM_CLOSE,0,0);
m_Dlg->DestroyWindow();
delete m_Dlg ;
return CWinThread::ExitInstance();
}求解 到底是哪里出错了...如何才能创建出来。。头疼了一天了

解决方案 »

  1.   

    我记得每个CWinThread里面都有个m_pMainWnd成员,一般要让它指向一个窗口,这里应该要指向你的那个m_Dlg吧
      

  2.   

    重点好像不在这里。。关键是 为啥那个AfxMessageBox不会弹出来。
    目标进程会卡掉
      

  3.   

    用CreateThread创建线程,然后在线程里弹MessageBox试下。
      

  4.   

    这样试试
    BOOL CWinThreadEx::InitInstance() 
    {     
      PostThreadMessage(::GetCurrentThreadId(),WM_SYSKEYDOWN,VK_MENU,0);
      AfxMessageBox("aa"); //这里的信息并没有弹出来...     
      m_Dlg->Create(IDD_DIALOG1,NULL); /这里创建窗口     
      m_Dlg->ShowWindow(SW_SHOW);     
      return TRUE; 
      

  5.   

    http://www.4ucode.com/Study/Topic/1353486
    参考
      

  6.   

    应该比较容易理解,你在目标进程中加载DLL,dll中显示一个窗口中,由于函数不返回,导致目标进程挂起,
    正确的办法是dll中显示窗口时用线程来完成,这样加载DLL能马上返回,目标进程就不会挂起没反应了。