LPCTSTR和char*之间的转换

方法一:

#include 

LPCTSTR str;
char* pNewStr;

USES_CONVERSION;//一定要加上这个宏

pNewStr = T2A(str);//调用A2T,T2A,T2W等进行转换

 

方法二:

    LPCTSTR str;

   int size= WideCharToMultiByte(CP_ACP,0,str,-1, NULL, 0, NULL,0);
   char * AsciiBuff =new char[size];
   WideCharToMultiByte(CP_ACP,0,str,-1,AsciiBuff,size, NULL, 0);
   char filename[MAX_PATH];
   strcpy(filename,AsciiBuff);
   delete AsciiBuff;

你可能感兴趣的:(LPCTSTR和char*之间的转换)