📜  c++ 将 const char* 转换为 LPCWSTR - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:51.331000             🧑  作者: Mango

代码示例1
const char *p = "D:\\";
  const WCHAR *pwcsName; //LPCWSTR
  
  // required size
  int size = MultiByteToWideChar(CP_ACP, 0, p, -1, NULL, 0);
  // allocate it
  pwcsName = new WCHAR[nChars];
  MultiByteToWideChar(CP_ACP, 0, p, -1, (LPWSTR)pwcsName, size);
  // use it....
    
  // delete it
  delete [] pwcsName;
}