首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

ATL项目中怎么将cstring转为string

2013-01-11 
ATL项目中如何将cstring转为string本帖最后由 jxsdpengbin 于 2012-12-28 16:05:40 编辑// server8.cpp :

ATL项目中如何将cstring转为string
本帖最后由 jxsdpengbin 于 2012-12-28 16:05:40 编辑 // server8.cpp : WinMain 的实现


#include "stdafx.h"
#include "resource.h"
#include "server8_i.h"
#include <atlstr.h>
#include <stdio.h>
using namespace ATL;
class Cserver8Module : public ATL::CAtlServiceModuleT< Cserver8Module, IDS_SERVICENAME >
{
public :
DECLARE_LIBID(LIBID_server8Lib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_SERVER8, "{2FA5D6ED-5A62-4B1A-A582-81EE32182A5D}")
HRESULT InitializeSecurity() throw()
{
// TODO : 调用 CoInitializeSecurity 并为服务提供适当的安全设置
// 建议 - PKT 级别的身份验证、
// RPC_C_IMP_LEVEL_IDENTIFY 的模拟级别
// 以及适当的非 null 安全说明符。

return S_OK;
}
};

Cserver8Module _AtlModule;



//
extern "C" int WINAPI _tWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, 
LPTSTR /*lpCmdLine*/, int nShowCmd)
{
CString cstr=_T("127.0.0.1");;
string  str;//编译不通过,报错,没有定义的string
//想通过cstr转为str后,传参给第三函数,因为第三方函数只接受string参数
return _AtlModule.WinMain(nShowCmd);
}

[解决办法]

引用:
引用:CString.GetBuffer(0);

ATL项目中 string 定义需要那些#include
#include<string>
#include<string.h>
还需要什么???

#include<string>
using namespace std;

热点排行