I found a way (but tell me if there are better ones):
- Component > Import component... > Import a Type Library > select the library
- Unit Dir Name = and uncheck "Generate Component Wrappers"
- "Add unit to MyProject.cbproj project" > Finish
- in the client class > File > Use Unit... > select the unit that was created
in the client class write this code for using the COM DLL:
CoInitialize(NULL); //Init COM library DLLs
ICompany *company;
HRESULT hr = CoCreateInstance ( CLSID_Company,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICompany,
(void**) &company );
if (SUCCEEDED (hr)) {
//TODO here you can use your company object!
//and finally release such resource
company->Release();
}
CoUninitialize();
Where Company
was the original class, exposed by the DLL, which I wanted to intantiate.
Introduction to COM - What It Is and How to Use It. helped me a lot.
Note that this requires the creation of *_TLB.* and *_OCX.* units. Is there a way that avoids it?