CString str="fdsfsdfsdf";
how to convert str to LPCWSTR?

解决方案 »

  1.   

    If your project is unicode version,then CString str = _T("fdsfsdfsdf"); str is the unicode string.
    you can use ATL macro A2W convert this to the unicode one.
    or you can use MultiByteToWideChar API.
      

  2.   

    LPCWSTR cwstr=A2CW(str);
    compile wrong?
      

  3.   


    //Method one: 
    CString str=_T("TestStr"); 
    USES_CONVERSION; 
    LPWSTR pwStr=new wchar_t[str.GetLength()+1]; 
    wcscpy(pwStr,T2W((LPCTSTR)str)); // Method two: 
     CString str=_T("TestStr"); 
    USES_CONVERSION; 
    LPWCSTR pwcStr = A2CW((LPCSTR)str); Just Browse from Internet,Try this two methods....