首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

VC 6.0中调用C#的COM组件,接收不到返回值~解决办法

2012-02-16 
VC 6.0中调用C#的COM组件,接收不到返回值~我的C#DLL源文如下usingSystemusingSystem.TextusingSystem.Se

VC 6.0中调用C#的COM组件,接收不到返回值~
我的C#DLL源文如下
using   System;
using   System.Text;
using   System.Security;
using   System.ComponentModel;
using   System.Collections.Generic;
using   System.Runtime.InteropServices;
using   System.Runtime.InteropServices.ComTypes;
using   System.Runtime.InteropServices.Expando;

namespace   poop
{
        [Guid( "62C34BED-DC67-4949-862C-431A2F5760E2 ")]
        public   interface   FFI
        {
                [DispId(1)]
                String   GetHello();
        }

        [Guid( "3B187428-A4EE-42df-A906-2F7BCFCB83B6 ")]
        [ClassInterface(ClassInterfaceType.AutoDispatch)]
        public   class   FFII   :   FFI
        {
                public   String   GetHello()
                {
                        return   "Hello! ";
                }
        }
}

在VC中的调用以Classwizard引入
然后加入
CoInitialize(NULL);
FFX   op;
AfxMessageBox(op.GetHello());
CoUninitialize();
为什么返回的是“”   空值呢?使用_bstr_t类型查看也是{ " ",1}
菜鸟问题~


问题比较菜~我人比较穷,谁叫我是应届生呢~只有15分省着点用啊~大家原谅啊~

[解决办法]
返回BSTR
[解决办法]
VC的返回值都应该是HRESULT吧?真正的返回是通过一个返回参数实现的。上面代码怎么通过编译的?

热点排行