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. Wrapping an existing COM object

Wrapping an existing COM object

Scheduled Pinned Locked Moved COM
comjsonhelpannouncement
4 Posts 2 Posters 0 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
    lemur2
    wrote on last edited by
    #1

    Hi, I'm not sure if this is possible, or whether it's been answered before but I've reached meltdown trying to guess the key phrase to get information on this. What I have is: - an existing COM DLL + idl etc which is installed in location A What I'd like to do is: write a new version of the DLL supporting the same interfaces as A so it is a complete replacement for A. However, I actually want to use the original DLL to do all the work. All the new DLL is for is to journal calls in and events out of the original and forward responses back to the client application. It may eventually multiplex information elsewhere, but that's the future. Any help would be greatly appreciated. I've been staring at MSDN too long to actually read the COM API clearly :sigh: Thanks. Kev

    J 1 Reply Last reply
    0
    • L lemur2

      Hi, I'm not sure if this is possible, or whether it's been answered before but I've reached meltdown trying to guess the key phrase to get information on this. What I have is: - an existing COM DLL + idl etc which is installed in location A What I'd like to do is: write a new version of the DLL supporting the same interfaces as A so it is a complete replacement for A. However, I actually want to use the original DLL to do all the work. All the new DLL is for is to journal calls in and events out of the original and forward responses back to the client application. It may eventually multiplex information elsewhere, but that's the future. Any help would be greatly appreciated. I've been staring at MSDN too long to actually read the COM API clearly :sigh: Thanks. Kev

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #2

      You can import the idl file in your new idl file to get the interface information from the old file. Please see the MIDL statement import. Note that the compiled DLL will not depend on the old DLL. You can opt to install only the new DLL on the target system. Another way to do it is to #import (VC++ feature) the DLL and its associated type library into your C++ code. A third way to do it is to grab the header file generated by the compilation of the IDL file beloning to the old DLL, and #include it in your new sources. Personally, I import import in the IDL file. Please note that by doing so, the corresponding header file of the imported IDL file, must also be accessible to the C++ compiler. At work I have an include files in one directory and IDL files in another (you can have them in one directory if you're not so anal about order it as I am :rolleyes:). I have added those two directories to the include search path in the IDE. That way MIDL finds the idl-file, and the C++ compiler finds the corresponding header file. -- Arigato gozaimashita!

      L 1 Reply Last reply
      0
      • J Jorgen Sigvardsson

        You can import the idl file in your new idl file to get the interface information from the old file. Please see the MIDL statement import. Note that the compiled DLL will not depend on the old DLL. You can opt to install only the new DLL on the target system. Another way to do it is to #import (VC++ feature) the DLL and its associated type library into your C++ code. A third way to do it is to grab the header file generated by the compilation of the IDL file beloning to the old DLL, and #include it in your new sources. Personally, I import import in the IDL file. Please note that by doing so, the corresponding header file of the imported IDL file, must also be accessible to the C++ compiler. At work I have an include files in one directory and IDL files in another (you can have them in one directory if you're not so anal about order it as I am :rolleyes:). I have added those two directories to the include search path in the IDE. That way MIDL finds the idl-file, and the C++ compiler finds the corresponding header file. -- Arigato gozaimashita!

        L Offline
        L Offline
        lemur2
        wrote on last edited by
        #3

        Hi, thanks for replying - all useful information. However, I don't think I made my question clear enough. What I am trying to achieve is to be able to install my binary-compatible version of an exisiting DLL onto a pre-existing system containing the original DLL. My new DLL would register itself and be the DLL loaded by clients of the original DLL. My DLL, because it knows that there is an existing DLL in a known location would be able to the original to provide the clients with identical functionality. If I was using plain DLL's I'd simply be able to install the new version so that it was found earlier in the path and load in the original DLL using LoadLibrary(). Since I know exactly what the interfaces are, I could do this with the COM DLL. However, I'm looking for an "official" COM way of short-circuiting the registry lookup. Kev

        L 1 Reply Last reply
        0
        • L lemur2

          Hi, thanks for replying - all useful information. However, I don't think I made my question clear enough. What I am trying to achieve is to be able to install my binary-compatible version of an exisiting DLL onto a pre-existing system containing the original DLL. My new DLL would register itself and be the DLL loaded by clients of the original DLL. My DLL, because it knows that there is an existing DLL in a known location would be able to the original to provide the clients with identical functionality. If I was using plain DLL's I'd simply be able to install the new version so that it was found earlier in the path and load in the original DLL using LoadLibrary(). Since I know exactly what the interfaces are, I could do this with the COM DLL. However, I'm looking for an "official" COM way of short-circuiting the registry lookup. Kev

          L Offline
          L Offline
          lemur2
          wrote on last edited by
          #4

          Aha! My foggy brain finally seems to be kicking into gear again. I believe the answer is to: 1) Call CoLoadLibrary() to load the specific DLL into memory 2) Call GetProcAddress() to get the original's DllGetClassObject() function. 3) Call DllGetClassObject() to get the original DLL's class-factory, then off-we-go! Pretty obvious really. Oh well :doh: I'll try this out later on today when shipping-hell lets me. Kev

          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