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);