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

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();

你可能感兴趣的:(String,null,Path)