Use Unicode and Hide the Console in Windows
来源:互联网 发布:mac拼音怎么打 编辑:程序博客网 时间:2024/05/21 14:54
If one would like to make his program being able to accept the arguments which is not English, the Unicode is requisite. That would make your software be more international. ( For me, it is instinct to use Chinese as file name and so forth.)
To use Unicode in windows, One could set your program as unicode in Visual Studio:
That your could use unicode in your code.
If your program arguments could be Chinese, the main should be the form:
int wmain(int argc, wchar_t *argv[])
in windows with unicode.
but, if you would like to hide console (for example, if you use Qt librarie with Visual Studio), the well-known solution :
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
would not work.
there would be :
error LNK2001: unresolved external symbol _main
To solve it as valid is very tricky, that is :
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:wmainCRTStartup")
To demostrate i, the code be :
#include <windows.h>#include <locale.h>#include <wchar.h>#ifndef _DEBUG#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:wmainCRTStartup")#endifint wmain(int argc, wchar_t *argv[]) { int k; k = 1; while(k < argc) { wchar_t bufferW[256]; memset(&bufferW[0], 0, 256*sizeof(wchar_t)); wcsncpy(&bufferW[0], argv[k], 256); #ifdef _DEBUG setlocale(LC_ALL, ""); wprintf(TEXT("%s\n"), &bufferW[0]); #else MessageBox(NULL, &bufferW[0], TEXT("參數"), MB_OK);#endif k++; }/*while*/ return 0;}/*wmain*/
and set the input argument as :
(Of course, do not forget set the character set as Unicode in the configuration properties -> General)
In the debug mode, the output would be in the console :
In the release mode, the console would be hidden, and the output be :
0 0
- Use Unicode and Hide the Console in Windows
- Hide the console in windows
- hide the task bar and input panel in Windows Mobile
- How use Instruments and display the console in Command Lines applications
- How to Access and Use the Windows Hosts File in Windows 7 and Vista
- Unicode in the Windows API
- Hide in the shadow
- Get the command parameters in Win app and Console app
- Coloring the Console Application (AddingText and Background color in C#)
- mysql++ use Unicode on Windows
- CrashMonkey4Android-use in windows
- Hide the columns in table-control
- HDU3988 Harry Potter and the Hide Story
- Harry Potter and the Hide Story HDU
- How to use Pageheap.exe in Windows XP, Windows 2000, and Windows Server 2003
- Hide Title Bar in C Windows Programming
- Deprecated: mysql_connect(): The mysqlextension is deprecated and will be removed in the future: use
- 解决mysql_connect(): The mysql extension is deprecated and will beremoved in the future: use mysqli or
- ++
- ———
- visio制作图形的基本技巧
- Ubuntu kylin-14.04 下配置 Hadoop 一:环境配置
- Ubuntu kylin-14.04 下配置 Hadoop 二:安装hadoop(单机模式)
- Use Unicode and Hide the Console in Windows
- 总结一下Word Break I 和 II
- Longest Increasing Subsequence
- hadoop配置文件及常用配置
- ajax 的简述与原理
- ——黑马程序员——OC中NSNumber、NSValue、NSDate 的使用总结
- LeetCode Edit Distance
- 冒泡排序:JAVA
- LeetCode 题解(284) : Smallest Rectangle Enclosing Black Pixels