콘솔에서 hinstance 얻기

jjuiddong
이동: 둘러보기, 찾기
// 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 );
}
개인 도구
이름공간

변수
행위
둘러보기
도구모음