在Borland C ++ Builder 4中使用.NET DLL时出现问题

时间:2022-09-01 23:51:19

I have created a COM callable DLL in C# .NET 2.0 and created a TLB from the assembly using the .NET regasm tool.

我在C#.NET 2.0中创建了一个COM可调用DLL,并使用.NET regasm工具从程序集创建了一个TLB。

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.

在Borland C ++ Builder 4.0中,我转到Project-> Import Type Library->并在那里找到我的DLL类型库,然后单击“Ok”导入它。

BCB creates an HardwareCheck_TLB.cpp & HardwareCheck_TLB.h file.

BCB创建一个HardwareCheck_TLB.cpp和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.

在项目的cpp文件中,我想使用我放的DLL:#include“HardwareCheck_TLB.h”在顶部。

Then in code if I try to declare an object of that type in code: IHardwareCheck hc = new IHardwareCheck();

然后在代码中,如果我尝试在代码中声明该类型的对象:IHardwareCheck hc = new IHardwareCheck();

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'.

我得到以下编译器错误:[C ++错误] Unit1.cpp(22):E2352无法创建抽象类'IHardwareCheck'的实例。 [C ++错误] Unit1.cpp(22):E2353类'IHardwareCheck'是抽象的,因为'__stdcall IHardwareCheck :: IsExpress(wchar_t * *,TOLEBOOL *)= 0'。

Anybody have any ideas how to get rid of this error?

任何人有任何想法如何摆脱这个错误?

Thanks!

2 个解决方案

#1


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).

无法使用new创建COM clasess。您需要使用CoCreateInstance系统调用(请参阅MSDN)或Borland提供的某些包装器(例如zer0_ring提到的那个)。

#2


It should generate some TCoClassCreatorT<> types that you can do a

它应该生成一些你可以做的TCoClassCreatorT <>类型

CoHardwareCheck::Create(&hc)

You may have to look at the tlibimp.exe that Borland distributes with its products. I've gone through this before with that program but never was able to get the Co classes generated, maybe you'll have better luck.

您可能需要查看Borland随其产品分发的tlibimp.exe。我之前已经完成了这个程序,但从未能够生成Co类,也许你会有更好的运气。

#1


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).

无法使用new创建COM clasess。您需要使用CoCreateInstance系统调用(请参阅MSDN)或Borland提供的某些包装器(例如zer0_ring提到的那个)。

#2


It should generate some TCoClassCreatorT<> types that you can do a

它应该生成一些你可以做的TCoClassCreatorT <>类型

CoHardwareCheck::Create(&hc)

You may have to look at the tlibimp.exe that Borland distributes with its products. I've gone through this before with that program but never was able to get the Co classes generated, maybe you'll have better luck.

您可能需要查看Borland随其产品分发的tlibimp.exe。我之前已经完成了这个程序,但从未能够生成Co类,也许你会有更好的运气。