콘솔에서 hinstance 얻기

jjuiddong
Jjuiddong (토론 | 기여) 사용자의 2013년 5월 19일 (일) 12:50 판

(비교) ← 이전 판 | 최신판 (비교) | 다음 판 → (비교)
이동: 둘러보기, 찾기

// console app

  1. include <iostream>

using namespace std;

  1. 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 );

}

개인 도구
이름공간

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