출처 : http://netur.egloos.com/5990062
## 전처리기 방식
// 멀티바이트 환경
#pragma comment(linker, "/entry:WinMainCRTStartup /subsystem:console")
// 유니코드 환경
#pragma comment(linker, "/entry:wWinMainCRTStartup /subsystem:console")
// # 전처리기방식 확장
#ifdef UNICODE
// 유니코드 환경
#pragma comment(linker, "/entry:wWinMainCRTStartup /subsystem:console")
#else
// 멀티바이트 환경
#pragma comment(linker, "/entry:WinMainCRTStartup /subsystem:console")
#endif
// #전처리기방식 한번 더 확장
// DEBUG 모드 일 때만
#ifdef _DEBUG
#ifdef UNICODE
// 유니코드 환경
#pragma comment(linker, "/entry:wWinMainCRTStartup /subsystem:console")
#else
// 멀티바이트 환경
#pragma comment(linker, "/entry:WinMainCRTStartup /subsystem:console")
#endif
#endif
##비주얼스튜디오 설정
속성 > 링커 > 시스템 탭 > 하위 시스템 : 콘솔
멀티바이트
속성 > 링커 > 고급 > 진입점 > WinMainCRTStartup
유니코드
속성 > 링커 > 고급 > 진입점 > wWinMainCRTStartup
##함수 호출방식
콘솔 생성 : AllocConsole();
콘솔 해제 : FreeConsole();
// 콘솔창 생성
AllocConsole();
// 표준 출력 핸들 얻음
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwByte(0);
// 출력할 문자열
char* strMsg = "Hello, World!";
// 출력
WriteFile(hConsole, strMsg, strlen(strMsg), &dwByte, NULL);
// 해제시 ( 바로 해제하면 출력 결과를 확인하기도 전에 없어져 버리니 나중에 해제 해야 함)
FreeConsole();
'CS > API' 카테고리의 다른 글
IOCP 강좌[데브피아-이기탁님] (0) | 2017.02.18 |
---|