惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - Michael Zhao

easyWeb2Pic -- 在IE浏览器中,将整个网页保存为BMP, JPEG/JPG, GIF, PNG或者TIFF图片 PeopleSoft Intergration Broker 设置及实列 网页保存利器——easyWebSave介绍 象IE收藏夹那样管理你从Web保存的文档(2) 网页保存利器——easyWebSave介绍 象IE收藏夹那样管理你从Web保存的文档(1) 网页保存利器——easyWebSave介绍 综述 Sharepoint中身份转换问题 Microsoft Sharepoint Service Access 2003 PeopleSoft 客户端安装 MFC ATL/WTL的一个技巧 上网浏览必备利器 -- easy Web Save easy Web Save 有人用过吗?可以把在网页的选择保存成HTML Complete, HTML Text Only, 甚至Word. 感觉挺方便的。 RES Protocol Inno Setup,有人用过吗? 免费的Installer 和 免费的Pascal Script Engine. Creating a Dialog-based App(转载) Unicode-enabling Microsoft C/C++ Source Code(转载) Int,Float,Char *,CString之间的转换(转载) Adding Entries to the Standard Context Menu(转载 from msdn) 你经常使用Baidu.com吗?
Building Unicode applications in MFC(转载)
Michael Zhao · 2005-05-13 · via 博客园 - Michael Zhao

What's The Point?
Windows NT4 and 2K run on Unicode. A great many of the net API functions provided by Microsoft® require Unicode and translating strings in and out of Unicode just to push them through these functions is a real pain. Building an application in Unicode not only allows easier access to these functions, but also creates code that runs optimally on NT operating systems.

NOTE - western releases of W9x don't support unicode. All releases of W9x only support a limited set of administrative net API calls which, as well as being ASCII, are often structured differently to their NT equivalents. The help files are fairly useless on leading you through the differences. The best way is to examine the respective header files for the function structures.

Project Settings
The first thing to ensure is that you have included the necessary Unicode libraries when installing your copy of Microsoft Visual Studio®. If you didn't do this when you first installed the tool, it's time to go back and remedy the omission.

Now you can go ahead and get the App Wizard to build you a project. Don't worry about Unicode for the moment, just work your way through the wizard as normal.

Once you've got a basic project up and running, all you need to do to make it build in Unicode is to tweak a couple of project settings. For debug builds, change the preprocessor directive to that shown below:

For release builds, change the preprocessor directives to that shown below:

If what you see in the preprocessor definitions box is substantially different from what you see above, don't panic. All you are trying to do is replace "_MBCS" with "_UNICODE" at the end of the string.

Finally you need to change the entry point symbol in the linker options:

Now the application will build using the Unicode libraries.

But this is only the first step. Now that the application builds in Unicode, you can't go on using the same old ASCII-type functions you always did. A little more refinement is required and here are a few hints on how to do it.

Unicode Programming
First of all, use MFC classes, particularly CStrings, wherever possible. They are overloaded to deal with both ASCII and Unicode.

When using string literals, you need to use the _T( ) macro to get the necessary conversion e.g.

AfxMessageBox(_T("This is a converted Unicode string literal"));

When using printf or the CString.Format() member function, the whole quoted section must be encapsulated by the _T( ) macro:

CString sExample;
sExample.Format(_T("Function failed, error code is %d"), GetLastError());

Don't use char[] types, use TCHAR[] instead (if you can't use a CString).

Below is a brief summary of some standard C++ function calls and their Unicode equivalents.

ASCII Unicode
strlen wcslen
strcpy wcscpy
itoa itow
atoi _wtoi
printf wprintf








And that, as they say, is all there is to it!