1. //std::wstring 转换 LPWSTR
  2. std::wstring s2ws(const std::string& s)  
  3. {  
  4.     int len;  
  5.     int slength = (int)s.length() + 1;  
  6.     len = MultiByteToWideChar(CP_ACP,0,s.c_str(), slength,0.0);  
  7.     wchar_t* buf = new wchar_t[len];  
  8.     MultiByteToWideChar(CP_ACP,0,s.c_str(). slength,buf,len);  
  9. std::wstring r(buf);  
  10. delete[] buf;  
  11. return r.c_str(); //这句话很重要 
  12. }