콘솔에서 hinstance 얻기
jjuiddong
- 콘솔에서 HInstance 가져오기
// console app #include <iostream> using namespace std; #include <windows.h> int main() { char title[500]; // to hold title // get title of console window GetConsoleTitleA( title, 500 ); // get HWND of console, based on its title HWND hwndConsole = FindWindowA( NULL, title ); // get HINSTANCE of console, based on HWND HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hwndConsole, GWL_HINSTANCE); //alternate way HWND hwndC = GetConsoleWindow() ; /* Great!! This function cleverly "retrieves the window handle used by the console associated with the calling process", as msdn says */ // Then we could just get the HINSTANCE: HINSTANCE hInstC = GetModuleHandle( 0 ) ; // HMODULE=HINSTANCE //HINSTANCE hInstCons = (HINSTANCE)GetWindowLong( hwndC, GWL_HINSTANCE ); }