CString str1 = "server1";
BSTR FAR* strServerName;怎么把str1的值赋给strServerName高手帮帮忙

解决方案 »

  1.   

    strServerName = str1.AllocSysString();
      

  2.   

    楼上方法我早用过啦
    error C2440: '=' : cannot convert from 'unsigned short *' to 'unsigned short ** '
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
      

  3.   

    MSDN明说了//typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CAtlString;CAtlString str("Soccer is best!");
    BSTR bstr = str.AllocSysString();// bstr now contains "Soccer is best!", and can be
    // passed to any OLE function requiring a BSTR.
    // Normally, if you pass the BSTR, you will
    // need to free the string after returning from the function call.
      

  4.   

    BSTR FAR* strServerName;
    AllocSysString返回的是BSTR类型
    你的是指针的指针
    所以
    BSTR FAR* strServerName=new BSTR;
    *p = str1.AllocSysString();