Results 1 to 9 of 9

Thread: How to silently register a DLL during VB runtime

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    341

    How to silently register a DLL during VB runtime

    The thing is, my project needs to referrence a few dlls that are not from Microsoft. So instead of manually register the dlls before running the program, is it possible to call Shell when the form is loaded?

    Yes, I tried and it seemed work. But there would be message boxes popping up to deliver the success information.

    So now come back to the question in the title ...

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,446

    Re: How to silently register a DLL during VB runtime

    You really do not want to do this.

    When you register DLLs and OCXs you are publishing them to all applications on the system. They are always considered shared libraries.

    This means they normally have a predefined location where they should be stored (the author should provide this via a .DEP file, but sadly many omit this step), AND it means your installer should be checking for the registered in-use count and incrementing it.

    When your uninstaller runs it decrements that counter and if it reaches 0 only then is it safe to unregister and remove the library file itself.

    If you fail to do this you risk breaking all other users of the library, both previously installed and subsequently installed, as soon as you remove the library file.


    So you really need to create a proper installer. "I don't know how" is not a reason: if you don't know how then you should not be trying to distribute your programs.

    In common usage InnoSetup does not create proper installers. Doing so means you must excercise extreme care in constructing your scripts. So much so that unless you are expert at installation that product should never be used, and even experts "blow it" frequently causeing DLL Hell for thousands of users.


    There is an exception to this, but it is an even more advanced topic: using reg-free COM isolation manifests.


    For the Average Joe the PDW which somes with every legal copy of VB6 is perfectly adequate and quite safe (by comparison with something like InnoSetup). Of course even then you can screw things up, because it isn't 1998 anymore and Windows has changed. Things that you had to redistribute with programs in the distant past can be unsafe to redistribute to modern versions of Windows.

  3. #3
    Addicted Member
    Join Date
    Jul 2006
    Posts
    159

    Re: How to silently register a DLL during VB runtime

    If they're only for your program, just install them to the same folder as your .exe and don't register.

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,286

    Re: How to silently register a DLL during VB runtime

    You should not manually register dlls nor should you do so by calling shell. You should create a proper installer that installs and registers these dlls.

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    2,223

    Re: How to silently register a DLL during VB runtime

    Quote Originally Posted by dilettante View Post
    There is an exception to this, but it is an even more advanced topic: using reg-free COM isolation manifests.
    This should be the default distribution form nowadays, so no registration needed and no registration happens at the client machines.

    Just download https://github.com/wqweto/UMMM and create a simple ini file with something like
    Code:
    Identity MyApp.exe
    File MyDll.dll
    File ThirdPartyControl.ocx
    Copy all the exe/dll/ocx files in a single folder, create the manifest file and zip all of it together. There you have a portable redist of your app.

    cheers,
    </wqw>

  6. #6
    Hyperactive Member Daniel Duta's Avatar
    Join Date
    Feb 2011
    Location
    Bucharest, Romania
    Posts
    359

    Re: How to silently register a DLL during VB runtime

    It is not very clear to me how that UMMM does work. There is no sample on GitHub and the vb source doesn't have any Form file within application. How to browse the exe/dll/ocx folder from UMMM.exe as long as it doesn't open any window?

  7. #7
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    2,223

    Re: How to silently register a DLL during VB runtime

    @Daniel Duta: It's "Unattended MMM" so yes, there is no UI. It's ini file driven utility aimed for use in automated builds.

    Basicly you create a MyApp.ini along with MyApp.prj and keep both under source control. There is a Sample.ini for quick help on the commands the utility can process. For instance MyApp.ini can include:
    Code:
    Identity MyApp.exe
    File MyDll.dll
    File ThirdPartyControl.ocx
    There is a command to reference ComCtl 6 assembly (Dependency ComCtl) if you need themes support in the final manifest too.

    cheers,
    </wqw>

  8. #8
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,930

    Re: How to silently register a DLL during VB runtime

    What's IMO worth to be mentioned is the more direct approach we have already available for nearly two decades now.

    The regfree instancing of ones ActiveX-Dlls per Standard-Dll-Helper (DirectCOM.dll)

    The approach is (IMO) much less confusing for a Newbie, compared with the Manifest-approach.

    I've just finished an appropriate article in the CodeBank, which tries to explain the needed steps
    (which is mostly: "how to get your folder- and file-placements right") in a "Newbie-friendly way".

    http://www.vbforums.com/showthread.p...rectCOM-Helper

    HTH

    Olaf

  9. #9
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    2,223

    Re: How to silently register a DLL during VB runtime

    @Olaf: Perfect for our components in ActiveX DLLs! Now, what can we do about those 3rd party ActiveX controls we placed all over our forms? Or am I missing something like Controls.Add replacement?

    Reg-free COM has a problem with licensed 3rd party controls on it's own. You have to deal with Licenses.Add in code (Sub Main) or most commercial controls will complain and run in demo mode or fail spectacularly. This includes Common Controls too which Microsoft unfortunately marked as licensed for no apparent reason.

    Here is how we deal with these:
    Code:
        '--- init licenses for reg-free COM
        If Not InIde Then
            Call Licenses.Add(PROGID_ACTIVEBAR, "...")
            Call Licenses.Add(PROGID_IMAGELIST, " qhj ZtuQha;jdfn[iaetr ")
            Call Licenses.Add(PROGID_UPDOWN, "9E799BF1-8817-11cf-958F-0020AFC28C3B")
            ...
        End If
    ... where licenses are extracted on a dev machine (with Licenses.Add again) and hard-coded in the app, so not everything is a drop-in replacement with reg-free COM too.

    Also note that Licenses collection is a per project singleton, if you have forms in a DLL you have to repopulate it in some DLL's routine (Sub Main) too before showing any form with these controls. This quickly becomes a serious pain point.

    Very interested to hear if there is some research on your part about UI controls instantiation.

    cheers,
    </wqw>

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