_bstr_t是com里面的一个类
一个简单的办法:
_bstr_t a = pVal;
pw = (char*)a;_bstr_t b = digest;
pOutVal = (BSTR)b; //这个可能还需要改动一下,你自己去调试一把

解决方案 »

  1.   

    还是报错:
    _bstr_t a = pVal;
    pw = (char*)a;
    报错如下:
    cannot convert parameter 2 from 'char *' to 'unsigned char *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    _bstr_t b = digest;
    pOutVal = (BSTR)b;
    报错如下:cannot convert from 'unsigned short *' to 'unsigned short ** '
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    如果我改为:
    _bstr_t b = digest;
    *pOutVal = (BSTR)b;//则报警告: warning C4800: 'unsigned char *' : forcing value to bool 'true' or 'false' (performance warning)
      

  2.   

    CComBSTR b(digest);
    *pOutVal=(BSTR)b;
      

  3.   

    编译这一句时报错: CComBSTR b(digest);error C2664: '__thiscall ATL::CComBSTR::ATL::CComBSTR(int)' : cannot convert parameter 1 from 'unsigned char [16]' to 'int'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
      

  4.   

    谢谢kimryo(轻*轻*前*轻*重),可以同你多交流吗?我的QQ是:2950878
    ICQ是:39407659
    MAIL:[email protected]
      

  5.   

    UCHAR*没有好的办法,可试试这样:  USES_CONVERSION;
      *pOutVal=SysAllocString(A2W((LPTSTR)digest));