Partager via


CWinApp::m_hInstance

Correspond au paramètre d' hInstance passé par windows à WinMain.

HINSTANCE m_hInstance;

Notes

Le membre d' m_hInstance est un handle vers l'instance actuelle de l'application s'exécute sous windows.Cela est retourné par la fonction globale AfxGetInstanceHandle.m_hInstance est une variable publique de type HINSTANCE.

Exemple

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

Configuration requise

Header: afxwin.h

Voir aussi

Référence

Classe de CWinApp

Graphique de la hiérarchie