Unicode下 TCHAR* 和CString转string的一种方法

来源:互联网 发布:百度云管家软件 编辑:程序博客网 时间:2024/04/30 04:41

1)TCHAR* 转string

 

     TCHAR exePathAndName[MAX_PATH];
    GetModuleFileName(NULL, exePathAndName, MAX_PATH);
     (_tcsrchr(exePathAndName,'//'))[1]=0;


    USES_CONVERSION;
    string filepath = T2A(exePathAndName);
    g_strDataDirecory = filepath + "data//";

 

2) CString转string

 

  CString m_cstrInputStr = L"Hello";

    USES_CONVERSION;

 string parens = W2A(m_cstrInputStr.LockBuffer());
 m_cstrInputStr.UnlockBuffer();

原创粉丝点击