在win32应用中使用printf代码示例
来源:互联网 发布:微盘交易平台源码 编辑:程序博客网 时间:2024/05/01 12:36
#include <windows.h>#include <stdio.h>/**If the program is supposed to run in the GUI subsystem - ie. the entry function is WinMain and the compiler/linker settings indicate GUI, then my AllocConsole etc. code will do the trick. If the program is supposed to run in the Console subsystem - ie. the entry function is main and the compiler/linker settings indicate Console, there''s no need for AllocConsole etc. This includes Glut based programs as well as siaspete''s comment. In fact, the suggestion is really the easiest. Change WinMain to main and use GetModuleHandle(NULL) to get the hInstance. Then use printf statements as you want. That the entry function is main rather than WinMain doesn''t mean you can''t register a class, create a window and enter into a message loop and so on.Or you can use the code pattern as below to show messages on a console.*/int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR lpszCmd,int nCmd){ AllocConsole(); // Create a new console window ::freopen("CONOUT$", "w", stdout); printf("Hello World!"); Sleep(5000); // Sleep for 5000 ms=5 s FreeConsole(); // Close the console window return 0;}
- 在win32应用中使用printf代码示例
- 在Win32中使用CString
- 在Win32中使用OpenGL
- printf()函数及其应用示例
- 在DataList中使用PagedDataSource类分页示例(代码)
- 代码示例:在母版页中使用UpdatePanel
- 在项目中简单使用枚举的示例代码
- 在java中使用dom4j解析xml(示例代码)
- 在java中使用dom4j解析xml(示例代码)
- 在java中使用dom4j解析xml(示例代码)
- 在java中使用dom4j解析xml(示例代码)
- 在窗口应用中使用printf,cout 等将输出重定向到console
- 在窗口应用中使用printf,cout 等将输出重定向到console
- 在窗口应用中使用printf,cout 等将输出重定向到console
- 如何在Visual Studio中直接使用示例代码浏览器搜索下载和管理代码示例
- 在 Freescale CodeWarrior 中使用 printf( ) 函数
- 不要在pthread线程中使用printf()
- 在MDK中使用printf及串口
- CXF 2.0 学习笔记-1(服务端)
- std::map的使用
- 装修
- 每个类一张表
- 使用mysql的命令行进行大文件的导入
- 在win32应用中使用printf代码示例
- ctags用法
- JAVA解惑--找零时刻
- 利用ffmpeg0.6.1把.h264纯码流打包成.mp4 .avi等格式
- 使用python爬虫抓站的一些技巧总结:进阶篇
- AJAX
- android u-boot.bin具体分析
- 详解extern "C"
- asp.net常用函数表