MFC-AfxGetMainWnd获取主线程句柄

 

    HANDLE handle = NULL;
    HANDLE handle1 = NULL;
    pwin = AfxGetApp();
    handle=AfxGetApp()->m_pMainWnd;//获得主线程的句柄

    CString str;
    str.Format(_T("主线程句柄=%d\r\n"), handle);
    ::OutputDebugString(str);

    handle1 = AfxGetMainWnd();//获取主线程句柄
    str.Format(_T("当前线程句柄=%d\r\n"), handle1);
    ::OutputDebugString(str);

 

 

 

 

posted @ 2023-04-12 07:56  天子骄龙  阅读(127)  评论(0)    收藏  举报