win32程序启用控制台
2016-02-24 10:06
399 查看
#include <cstdio> #define USE_WIN32_CONSOLE int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); #ifdef USE_WIN32_CONSOLE AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); #endif // TODO: Place code here. // Initialize global strings LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadStringW(hInstance, IDC_WIN32TEST, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WIN32TEST)); MSG msg; // Main message loop: while (GetMessage(&msg, nullptr, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } #ifdef USE_WIN32_CONSOLE FreeConsole(); #endif return (int) msg.wParam; }
主要是12-17行,46-48行的部分.
相关文章推荐
- drools
- OpenCV命名规则
- 对广告的处理
- CART算法
- @SuppressWarnings含义
- C++ inline 函数
- hive UDF 提取文本中的地名
- javascript parseInt函数详解
- RIOT 基于CC2538cb套件学习2,编译测试default和helloword
- Ubuntu的目录与第三方库
- iOS开发——遍历目录,获取文件名列表
- Java中Comparable和Comparator实现对象比较
- 使用js获取表单中各个name的值
- 两种状态分别DP+分类讨论(2577)
- SQLite的管理与C#应用
- swift-函数04-函数作为参数,返回值,输入输出参数
- 非常简单的适用的ajax提交数据
- Android CollapsingToolbarLayout设置背景图片后如何透明状态栏
- Swift学习笔记十三:继承
- 谷歌浏览器离线版