views:

581

answers:

2

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

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 creates an HardwareCheck_TLB.cpp & HardwareCheck_TLB.h file.

In a cpp file of the project I want to use the DLL I put: #include "HardwareCheck_TLB.h" at the top.

Then in code if I try to declare an object of that type in code: 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'.

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

Thanks!

A: 

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

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.

+2  A: 

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

Roman Plášil