在Borland C ++ Builder 4中使用.NET DLL出现问题 [英] Trouble using .NET DLL in Borland C++ Builder 4
问题描述
我已经在C#.NET 2.0中创建了一个COM可调用DLL,并使用.NET regasm工具从程序集中创建了TLB
。
I have created a COM callable DLL in C# .NET 2.0 and created a TLB from the assembly using the .NET regasm tool.
在Borland C ++ Builder 4.0中,我转到Project-> Import Type Library->,然后
在此处找到我的DLL的类型库,然后单击确定将其导入。
In Borland C++ Builder 4.0 I go to Project->Import Type Library-> and find my DLL's type library there and click "Ok" to import it.
BCB创建了HardwareCheck_TLB.cpp& HardwareCheck_TLB.h文件。
BCB creates an HardwareCheck_TLB.cpp & HardwareCheck_TLB.h file.
在项目的cpp文件中,我要使用DLL:
#include HardwareCheck_TLB.h
在顶部。
In a cpp file of the project I want to use the DLL I put: #include "HardwareCheck_TLB.h" at the top.
然后在代码中,如果我尝试在代码中声明该类型的对象:
IHardwareCheck hc = new IHardwareCheck();
Then in code if I try to declare an object of that type in code: IHardwareCheck hc = new IHardwareCheck();
我收到以下编译器错误:
[C ++错误] Unit1.cpp(22):E2352无法创建抽象
类'IHardwareCheck'的实例'。
[C ++错误] Unit1.cpp(22):E2353类 IHardwareCheck是抽象的
,因为 __stdcall IHardwareCheck :: IsExpress(wchar_t * *,TOLEBOOL
*)= 0。
I get the following compiler error: [C++ Error] Unit1.cpp(22): E2352 Cannot create instance of abstract class 'IHardwareCheck'. [C++ Error] Unit1.cpp(22): E2353 Class 'IHardwareCheck' is abstract because of '__stdcall IHardwareCheck::IsExpress(wchar_t * *,TOLEBOOL *) = 0'.
任何人都知道如何消除此错误?
Anybody have any ideas how to get rid of this error?
谢谢!
推荐答案
不能使用new创建COM分类。您需要使用CoCreateInstance系统调用(请参阅MSDN)或Borland提供的某些包装器(例如zer0_ring提到的包装器)。
COM clasess cannot be created using new. You need to use the CoCreateInstance system call (see MSDN) or some wrapper provided by Borland (such as the one mentioned by zer0_ring).
这篇关于在Borland C ++ Builder 4中使用.NET DLL出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!