How to create isolated/reg-free COM between Visual Basic DLLs and a C++ DLL?

后端 未结 2 2017
臣服心动
臣服心动 2021-01-15 17:52

I have to use a VB (COM) DLL in a C++ DLL. I figured out how to access the VB (COM) DLL from the C++ DLL and it works.

Now I\'ve got the problem that I have to use i

2条回答
  •  无人共我
    2021-01-15 18:16

    You are making an oddly common mistake, expecting Windows to solve the chicken-and-egg problem. A brief word about the way manifest works might help.

    Windows loads the content of a manifest when it load an executable file, the entries are added to an internal lookup table. Whenever an application first asks to create a COM object, underlying call is CoCreateInstance() which supplies the CLSID guid, it first consults that lookup table. If the CLSID is a match then the entry tells it what DLL must be loaded. If there is no match then it falls back to the traditional registry lookup.

    The chicken-and-egg is that your DLL didn't get loaded yet. So its manifest entries are not yet active.

    The egg must come first, the entry needs to go into the manifest you embed in the C++ executable. Like this:

      
        
        
        
        
      
    

    MSDN article is here.

提交回复
热议问题