win32中如何使用CString

来源:互联网 发布:java权限管理实例 编辑:程序博客网 时间:2024/05/17 07:47
 MFC中CString的强大,感觉很方便,Win32里是没有CString的,怎么去使用呢?

     在StdAfx.h中加入头文件#include "AFX.h",注意加在#include<windows.h>之前,编译后会发现

    Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d] C:\Program Files (x86)\Microsoft Visual Studio 8\VC\ce\atlmfc\include\AFX.h 24

这里错误提示的意思是缺少_AFXDLL这个宏,因此在Project——>property中,C/C++里面Preprocessor(预编译),加入_AFXDLL这个宏,OK搞定!!

 

    程序运行后,突然执行到析构函数,自动退出,这种情况下没有错误提示,解决方法是Project->property,link->system中Stack Reserve Size 设为0,Stack Commit Size也设为0.

     看错误提示,是件学习的过程,不能不会啊!!

     这里记录下来,防止下次忘了


// tt.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#define _AFXDLL
#include "AFX.h"
int _tmain(int argc, _TCHAR* argv[])
{
CString t;
t.Format(_T("111111111111"));
return 0;
}




0 0
原创粉丝点击