작업2018. 5. 18. 13:40

Window App에서 console띄워서 printf나 wprintf로 로그 보기(winapi, c++)


#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    AllocConsole();

    HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
    int hCrt = _open_osfhandle((long) handle_out, _O_TEXT);
    FILE* hf_out = _fdopen(hCrt, "w");
    setvbuf(hf_out, NULL, _IONBF, 1);
    *stdout = *hf_out;

    HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
    hCrt = _open_osfhandle((long) handle_in, _O_TEXT);
    FILE* hf_in = _fdopen(hCrt, "r");
    setvbuf(hf_in, NULL, _IONBF, 128);
    *stdin = *hf_in;

    // use the console just like a normal one - printf(), getchar(), ...
}

출처 : https://justcheckingonall.wordpress.com/2008/08/29/console-window-win32-app/

'작업' 카테고리의 다른 글

Drag Tracker  (0) 2015.02.17
12/9 해야할 일  (0) 2011.12.09
Posted by Gromit.kr
작업2015. 2. 17. 09:11

SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &m_bDragTraker, 0);

SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, false, 0, 0);

Posted by Gromit.kr
작업2011. 12. 9. 10:02
뉴질랜드 여행기 쓰기
사진 정리하기 
동영상정리하기
엔도몬도에 gps트래킹 로깅한것 정리해서 업데이트하기

인터넷전화기.
후드티받기(챠콜)
연어훈제 요리 해보기

'작업' 카테고리의 다른 글

Window App에서 console띄워서 printf나 wprintf로 로그 보기(winapi, c++)  (0) 2018.05.18
Drag Tracker  (0) 2015.02.17
Posted by Gromit.kr