Results 1 to 14 of 14

Thread: VB6 with DLL

Threaded View

  1. #8
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: VB6 with DLL

    Quote Originally Posted by Nightwalker83 View Post
    What is the difference between an ActiveX DLL and a normal DLL, what is activeX and why does it need to be registered?
    ActiveX DLLs are actually COM servers. They export services through interfaces. Now COM was meant to be a cure for DLL hell or some such thing. Weather it brought more problems than it solved is debatable, non-the-less, the approach they took was to require all COM classes(I believe co-classes is the correct technical jargon), interfaces and methods to all be identified by GUIDs to ensure uniqueness. This way you can have multiple versions of a single COM server existing side by side without problems because the COM clients would be bound against the IDs of whatever version it was compiled against. Every time you compile an ActiveX DLL, new IDs are generated for the interfaces, classes, and methods.

    Now, all this information about the ActiveX DLLs interfaces is stored in something called a type library. They can either be embedded inside the DLL or separately in a .TLB file. Now when you register an ActiveX DLL, what happens is that the information about the classes and interfaces is written into the registry, otherwise COM clients would not be able to find them. When you compile a VB6 program that uses a COM interface like say, IPicture, its not actually binding to something called IPicture but rather an interface ID. The IID for IPicture is 7BF80980-BF32-101A-8BBB-00AA00300CAB. That is what your VB6 app looks for whenever you call on IPicture. That is how COM actually works. Using names is only a convenience for the programmer writing and/or using the interface. COM doesn't care about interface names, only IDs.

    Another thing you should note is that typically registration is done by the ActiveX DLL itself. When you compile an ActiveX DLL in VB6 it actually exports two C style methods, DllRegisterServer and DllUnregisterServer. What actually happens when you call Regsvr32 on ActiveX DLLs is that it calls one of these functions depending on weather you're registering or unregistering it.
    Last edited by Niya; Aug 4th, 2013 at 09:02 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width