Finally I found a way (tell me if there are better ones):
- Component > Import component... > Import a Type Library > select the library
- Unit Dir Name = <my project folder> 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 connecting to B1:
CoInitialize(NULL); //Init COM library DLLs ICompany *company; HRESULT hr = CoCreateInstance ( CLSID_Company, NULL, CLSCTX_INPROC_SERVER, IID_ICompany, (void**) &company ); if (SUCCEEDED (hr)) { company->UserName = String("manager").c_str(); company->Password = String("xxxxxxxxx").c_str(); company->language = BoSuppLangs::ln_Italian; company->Server = String("192.168.81.122").c_str(); company->DbServerType = BoDataServerTypes::dst_MSSQL2008; company->CompanyDB = String("SBODemoIT").c_str(); //I must set these 3 properties company->UseTrusted = false; company->DbUserName = String("sa").c_str(); company->DbPassword = String("yyyyyyyyy").c_str(); //while if I only set following property it gives me error -132 company->LicenseServer = String("192.168.81.122:30000").c_str(); int result = company->Connect(); if (result != 0) { handleError(result); return; } ShowMessage("Connected!"); company->Disconnect(); ShowMessage("Disconnected!"); company->Release(); } CoUninitialize();
Note that this requires the creation of *_TLB.* and *_OCX.* units. Is it possible to avoid it?