[英]C++ using C# DLL. Problem with InvokeHelper
我有一个ac#dll,真的很简单:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassTestPourCPP
{
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)]
public class MainClass
{
public int GiveInt2()
{
return 2;
}
}
}
我希望我的C ++应用程序(VC6)使用它。 因此,我在启用“设置对com可见”的选项的情况下构建了自己的dll。 我给DLL加气,所以有了tlb文件。 然后我将tlb导入到IDE中,它生成了一个.h&.cpp文件,完全应该如此。
long _MainClass::GiveInt2()
{
long result;
InvokeHelper(0x60020004, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
return result;
}
现在的问题是,当我调用该方法时,它只是..没什么,给我一个错误的输出(它在调用之前给出了结果的值,就像InvokeHelper中是否有try catch一样)
为什么不起作用? :(
非常感谢你!
在尝试使用COM对象之前,您是否致电CoInitialize
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.