TCHAR转为char

来源:互联网 发布:冰冰办公软件 编辑:程序博客网 时间:2024/04/28 09:30


//将TCHAR转为char   
//ptchar是TCHAR类型指针,pchar是char类型指针   
TcharToChar (const TCHAR * ptchar, char * pchar)  
 
    int iLength  
    //获取字节长度   
   iLength WideCharToMultiByte(CP_ACP, 0, ptchar, -1, NULL, 0, NULL, NULL);  
   //将ptchar值赋给pchar    
   WideCharToMultiByte(CP_ACP, 0, ptchar, -1, pchar, iLength, NULL, NULL);   
 




  1. //将char转为TCHAR
  2. //ptchar是TCHAR类型指针,pchar是char类型指针  
  3. CharToTchar (const char pchar, TCHAR * ptchar)  
  4.  
  5.     int iLength   
  6.     iLength MultiByteToWideChar (CP_ACP, 0, pchar, strlen (pchar) 1, NULL, 0)  
  7.     MultiByteToWideChar (CP_ACP, 0, pchar, strlen (pchar) 1, ptchar, iLength)  





原创粉丝点击