Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. compilation problem with #import

compilation problem with #import

Scheduled Pinned Locked Moved COM
comhelpc++debuggingjson
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lily18
    wrote on last edited by
    #1

    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 it ConDll ->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 IDispatch OLECHAR* 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

    G 1 Reply Last reply
    0
    • L Lily18

      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 it ConDll ->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 IDispatch OLECHAR* 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

      G Offline
      G Offline
      Gertjan Schuurmans
      wrote on last edited by
      #2

      Hi 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups