CWinApp::m_hInstance
对应于Windows传递的 hInstance 参数传递给 WinMain。
HINSTANCE m_hInstance;
备注
是处理对应用程序的当前实例运行在Windows下的 m_hInstance 数据成员。 这是通过全局函数 AfxGetInstanceHandle返回。 m_hInstance 是类型 HINSTANCE的公共变量。
示例
// Typically you do not need to pass the application's hInstance
// to Windows APIs directly because there are equivalent MFC
// member functions that pass the hInstance for you. The following
// example is not typical:
HCURSOR hCursor;
hCursor = ::LoadCursor(AfxGetApp()->m_hInstance,
MAKEINTRESOURCE(IDC_MYCURSOR));
// A more direct way to get the application's hInstance is to
// call AfxGetInstanceHandle:
hCursor = ::LoadCursor(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDC_MYCURSOR));
// If you need the hInstance to load a resource, it is better
// to call AfxGetResourceHandle instead of AfxGetInstanceHandle:
hCursor = ::LoadCursor(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDC_MYCURSOR));
// A better way to load the cursor resource is to call
// CWinApp::LoadCursor
hCursor = AfxGetApp()->LoadCursor(IDC_MYCURSOR);
要求
Header: afxwin.h