CString转换为const char*

LPCTSTR Str = str.GetBuffer();

		// CString转换为const char*
		DWORD dwMinSize;
		dwMinSize=WideCharToMultiByte(CP_ACP,NULL,Str,-1,NULL,0,NULL,FALSE);
		char * pp=new char[dwMinSize];
		WideCharToMultiByte(CP_OEMCP,NULL,Str,-1,pp,dwMinSize,NULL,FALSE);
        pEle->SetAttribute("Value", pp);
        pRootEle->LinkEndChild(pEle);

你可能感兴趣的:(CString转换为const char*)