Reputation: 347
I have a third part DLL written in Visual Basic that I'm trying to use from C++. I don't have it source and header files, and just have documentation about which its classes and methods including their signature.
I found some articles stating that I could not use that dll directly because it was written in Visual Basic, which is managed, and I should use it through COM by
Registering the DLL: regasm /codebase /tlb:ThirdPartyDll.tlb ThirdPartyDll.dll
Importing it: #import "../Debug/ThirdPartyDll.tlb"
Initializing COM: CoInitialize(NULL);
Instantiating the object: ThirdPartyClassPtr ptrThirdPartyClass(_uuidof(ThirdPartyDll::ThirdPartyClass));
Calling a method of the object: ptrThirdPartyClass->ThirdPartyClassMethod();
I'm having the following 2 problems
A. The dll was registered successfully in step #1 with warnings such as the following one that I ignored because they mentioned classes that I don't need.
Type library exporter warning processing ThirdPartyDll.AnotherClassThatIDontUse, ThirdPartyDll. Warning: Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute.
B. None of the methods available in ThirdPartyClassPtr class are visible in the C++ code. The only methods that can be called are the following ones, and they were not defined by the ThirdPartyClass, but by something else (probably by the compiler when it processed the import command).
Any ideas what could be wrong?
Upvotes: 1
Views: 235
Reputation: 2060
If it is a VB.NET Dll, to learn how it works, I would start with writing a dummy project (C#, VB, whatever you prefer) using the dll, then you see the methodes, properties and so on, and then you should be able to translate this
Upvotes: 1