如下代码编译都通不过。
STDMETHODIMP CDataType::get_srvList(BSTR *pVal)
{
// TODO: Add your implementation code here
std::string a("hello");
*pVal=_com_util::ConvertStringToBSTR(a.c_str());
return S_OK;
}
--------我当如何是好???-----------

解决方案 »

  1.   

    不会吧,什么错误
    不会是没include"string"和"comutil.h"吧
      

  2.   

    如果是链接错误再加上:
    #pragma comment(lib, "comsupp.lib")
      

  3.   

    刚才是没有include comutil.h
    它还要什么库??? 
    error LNK2001: unresolved external symbol "unsigned short * __stdcall _com_util::ConvertStringToBSTR(char const *)" (?ConvertStringToBSTR@_com_util@@YGPAGPBD@Z)
    Debug/ComACE.dll : fatal error LNK1120: 1 unresolved externals
      

  4.   

    #pragma comment(lib, "comsupp.lib")
      

  5.   

    新问题。如果看到了就回,没看到就算了。
    如果有两个string怎么办?
    比如string a("hello"),b("world");
    *pVal=_com_util::ConvertStringToBSTR(a.c_str());
    ?????
    下面如何是好?
      

  6.   

    是啊。要把a+b 给*BSTR
      

  7.   

    char* pA = a.c_str();
    char* pB = a.c_str();
    strcat(pA, pB);
    *pVal=_com_util::ConvertStringToBSTR(pA);
      

  8.   

    用SAFEARRAY吧,或者把所有字符串写成****,*****,****的形式,客户端再split一下
      

  9.   

    对,用strcat函数就可以了:*pVal=_com_util::ConvertStringToBSTR(strcat((char *)a.c_str(),(char *)b.c_str()));
      

  10.   

    高人都是高人。
    我想知道多一点关于splitter和StringCchCat??