compilation problem with #import
-
I need to use activex dll created in vb in a C++ program. I use vc 6. Here is what I do:
#import " MADLL1.dll" \ named_guids no_implementation \ raw_interfaces_only raw_native_types using namespace MADLL1; #import " MADLL2.dll" no_implementation \ no_auto_exclude \ raw_native_types raw_interfaces_only \ named_guids using namespace MADLL2; #import " MADLL3.dll" no_implementation \ no_auto_exclude \ raw_native_types raw_interfaces_only \ named_guids rename("SOMETHING"," SOMETHINGX") \ rename(" SOMETHINGELSE", " SOMETHINGELSE X") \ using namespace MADLL3;
My problem is with the third dll. I put rename because I had compilation errors.I taught It was name collision. I did help with these variable but I have still alot of erros of the same kind: Ex : c:\inwork\opc_da_clientmerge\debug\OLEGEUSE.tlh(729) : error C2059: syntax error : 'constant' enum TT_SOMETHING { TTDT_ONE = 0,///Here I should rename these variables TTDT_TWO= 1, TTDT_THREE= 2, TTDT_FOUR= 3 }; Is it normal to rename everything? I don't think so. Here is how I want to use the dll:HRESULT hresult; CLSID clsid; CoInitialize(NULL); //initialize COM library hresult=CLSIDFromProgID(OLESTR("madll.clsConnexion"), &clsid); //retrieve CLSID of component if(FAILED(hresult)) { TRACE_MSG(_T("CDataBD:: GetTypeAttr"),hresult); return hresult; } _clsConnexion *ConDll; //fromdll1 _clsError *Error; //fromdll3 hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsConnexion),(LPVOID *) &t); if(FAILED(hresult)) { TRACE_MSG(_T("CDataBD:: GetTypeAttr"),hresult); return hresult; }
//to this point everything works but for the rest I have to load the third dll to test itConDll ->LoadData("01", "L4", 0, 0, m_Line, "OLE.MachineS", ADO_OLEDB, Error); ConDll->Release(); //call method CoUninitialize(); //Unintialize the COM library
I also tried with IDispatchOLECHAR* name = OLESTR("LoadData"); HRESULT hr2 = pDispatch->GetIDsOfNames(IID_NULL, &name, 1, GetUserDefaultLCID(), &dispid);
Thinking I could use Invoke.... But I received : DISP_E_UNKNOWNNAME I'm able to use these Interfaces : ITypeLib ITypeInfo I have access to info from the lib but not Invoke... You see that I tried different approches without success. Is it me that don't understand or could it be how the dll was created? I have -
I need to use activex dll created in vb in a C++ program. I use vc 6. Here is what I do:
#import " MADLL1.dll" \ named_guids no_implementation \ raw_interfaces_only raw_native_types using namespace MADLL1; #import " MADLL2.dll" no_implementation \ no_auto_exclude \ raw_native_types raw_interfaces_only \ named_guids using namespace MADLL2; #import " MADLL3.dll" no_implementation \ no_auto_exclude \ raw_native_types raw_interfaces_only \ named_guids rename("SOMETHING"," SOMETHINGX") \ rename(" SOMETHINGELSE", " SOMETHINGELSE X") \ using namespace MADLL3;
My problem is with the third dll. I put rename because I had compilation errors.I taught It was name collision. I did help with these variable but I have still alot of erros of the same kind: Ex : c:\inwork\opc_da_clientmerge\debug\OLEGEUSE.tlh(729) : error C2059: syntax error : 'constant' enum TT_SOMETHING { TTDT_ONE = 0,///Here I should rename these variables TTDT_TWO= 1, TTDT_THREE= 2, TTDT_FOUR= 3 }; Is it normal to rename everything? I don't think so. Here is how I want to use the dll:HRESULT hresult; CLSID clsid; CoInitialize(NULL); //initialize COM library hresult=CLSIDFromProgID(OLESTR("madll.clsConnexion"), &clsid); //retrieve CLSID of component if(FAILED(hresult)) { TRACE_MSG(_T("CDataBD:: GetTypeAttr"),hresult); return hresult; } _clsConnexion *ConDll; //fromdll1 _clsError *Error; //fromdll3 hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsConnexion),(LPVOID *) &t); if(FAILED(hresult)) { TRACE_MSG(_T("CDataBD:: GetTypeAttr"),hresult); return hresult; }
//to this point everything works but for the rest I have to load the third dll to test itConDll ->LoadData("01", "L4", 0, 0, m_Line, "OLE.MachineS", ADO_OLEDB, Error); ConDll->Release(); //call method CoUninitialize(); //Unintialize the COM library
I also tried with IDispatchOLECHAR* name = OLESTR("LoadData"); HRESULT hr2 = pDispatch->GetIDsOfNames(IID_NULL, &name, 1, GetUserDefaultLCID(), &dispid);
Thinking I could use Invoke.... But I received : DISP_E_UNKNOWNNAME I'm able to use these Interfaces : ITypeLib ITypeInfo I have access to info from the lib but not Invoke... You see that I tried different approches without success. Is it me that don't understand or could it be how the dll was created? I haveHi there, My guess is that MADLL3 typelibrary implicitly imports typelibs of MADLL2 or MADLL1, this causes all kinds of typedefs to be duplicated in the generated .tlh and .tli files. Gertjan