if using MFC AfxGetInstanceHandle(). For console programs, call GetConsoleWindow() to get the HWND then GetWindowLong() to get the HINSTANCE.
HINSTANCE hInst= GetModuleHandle (0);
For the Win32 API, you could also use GetModuleHandle():
HINSTANCE hInst= GetModuleHandle (0);