次の方法で共有


CWinApp::m_hInstance

更新 : 2007 年 11 月

Windows から WinMain に渡されたパラメータ hInstance に相当します。

HINSTANCE m_hInstance;

解説

m_hInstance データ メンバは、現在 Windows で実行しているアプリケーションのインスタンスへのハンドルです。この値は AfxGetInstanceHandle グローバル関数から返されます。m_hInstanceHINSTANCE 型のパブリック変数です。

使用例

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

必要条件

ヘッダー : afxwin.h

参照

参照

CWinApp クラス

階層図

その他の技術情報

CWinApp のメンバ