原型为:
STDMETHODIMP CConvertDll::ConvertRtfToText(LPTSTR a_RtfText, LPTSTR a_Text)
其中a_RtfText为in,a_Text为out

解决方案 »

  1.   

    那是因为你那是一个指针,而你没有指定大小,当需要做marshal的时候,无法确定你的指针数据到底有多少,所以会报错,你要传字符串最好是使用BSTR,不要使用LPTSTR之类的,而且你的定义上还有错误,对于out类型的,你那里应该要使用LPTSTR* a_text才对,有一本专门介绍IDL的书籍,你可以上china-pub去看看(和COM本质论是一个系列的),看看那本书对你会有些帮助的
      

  2.   

    MIDL2041 : [out] only parameter cannot be an unsized string An array with the string attribute has been declared as an out-only parameter without any size specification. The server stub needs size information to allocate memory for the string. You can remove the string attribute and add the size_is attribute, or you can change the parameter to an in, out parameter
      

  3.   

    HRESULT ReturnAStringWithSize([out] long* lSize, [out, size_is(*lSize)] char* pszOut);好像是这样的,我也记不清了,你自己先试试吧
      

  4.   

    建议使用BSTR或者_bstr_t(它对BSTR进行封装),BSTR是可以不用遍历字符串就知道他的长度的,他之前的四个字节是他的长度
      

  5.   

    为什么我用BSTR,返回的只是一个字符而不是一个字符串?我是这样调用的:CString tmpStr = "asdfsad";
    BSTR strResult = tmpStr.AllocSysString();
    return strResult;
      

  6.   

    BSTR 是UNICODE字符,Tools的Options菜单中的Debug选项卡中钩上Display unicode strings,你就能看到全部字符了
      

  7.   

    可是在ATL COM中把参数设置为BSTR,编译出错如下:
    [out] only parameter must not derive from a top-level [unique] or [ptr]
      

  8.   

    你好,用LPSTR* 编译可以通过,可怎么取出该变量的内容阿?