Results 1 to 18 of 18

Thread: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    When I compile an ActiveX DLL file, instead of simply leaving it unregistered, and giving me the chance to do with it what I want (of which I have 2 choices, run regsvr32 to register it, or run 3rd party software such as UMMM to create SxS info for it so that it doesn't need to be registered), VB6 goes ahead an registers it WITHOUT ANY INPUT FROM ME.

    Is there a way to STOP VB6 from auto-registering activex DLLs? Every single time I compile a DLL, it registers it, and then if I make the mistake of deleting the file before running "regsvr32 /u mycomponent.dll", it leaves a boatload of registry entries, that I need to manually remove via REGEDIT, which is a VERY LENGTH PROCESS. Regsvr32, unfortunately, does NOT remove registry entries associated with a given file name (such as "mycomponent.dll") unless the actual file is still on the harddrive. This seems to be a major oversight on MS's part.

    So it seems that VB6.exe (or one of the components loaded in its memory space such as vba6.dll or vb6ide.dll) is either invoking regsvr32.exe, or is directly calling the Windows API registry functions, in order to register my activex dll, without my permission.

    My post here, is asking one thing. Is there SOME WAY to disable this automatic registration of activex dlls? Otherwise it makes it a PAIN to clean up the registry, if I forgot that the component was still registered, and went ahead and deleted the the DLL file without having unregistered it.

    I've actually spent up to a HOUR searching for the last remnants of the registry entries for a DLL that I'd mistakenly deleted and emptied the recycle bin, often having to first search for the filename of the DLL in the registry, and then from there getting the GUID, and doing a registry search for all registry keys and values containing that GUID, as well as all registry keys and values containing the name of the component. And then deleting them all manually.

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    If you run Windows 10 it is easy, just compile the DLL with the IDE not elevated.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    Quote Originally Posted by Eduardo- View Post
    If you run Windows 10 it is easy, just compile the DLL with the IDE not elevated.
    That doesn't work. VB6 needs Windows XP compatibility activated for VB6.exe or it won't even run. Running any EXE in compatibility mode automatically gives it admin permissions.

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,904

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    I don't know anything about preventing the IDE from automatically registering activex components, but the IDE does not need any compatibility mode when running on W10

  5. #5
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,389

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    You can include the regsvr32 register/unregister directly in the shell context menu.

    So after compilation it is very quick to right click the dll and click unregister.

    That's at least my way..

  6. #6
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    Quote Originally Posted by Ben321 View Post
    That doesn't work.
    Did you try it?

    Quote Originally Posted by Ben321 View Post
    VB6 needs Windows XP compatibility activated for VB6.exe or it won't even run.
    No. At least I never experienced that behavior.

    Quote Originally Posted by Krool View Post
    You can include the regsvr32 register/unregister directly in the shell context menu.

    So after compilation it is very quick to right click the dll and click unregister.

    That's at least my way..
    Yes, that's handy. But I never remember how it must be done. I did that a couple of times but were lost after Windows reinstallations.

    What I do is to place a couple of bat files on the desktop to register and unregister the file I'm working on.

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    Ben,

    Here (attached) are a couple of VB Script files that I often used. I virtually never leave my DLLs registered, as I manually load them with some code The Trick developed.

    So, for testing purposes, I always immediately unregister them after I compile them.

    To use these scripts, you can just drag the DLL onto the one you want.

    Actually, to give credit where it's due, I believe Dilettante originally developed these scripts.
    Attached Files Attached Files
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  8. #8
    Hyperactive Member
    Join Date
    Jun 2016
    Location
    EspaƱa
    Posts
    508

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    and if you add the plugin to the script.
    and every time it is compiled automatically it will be uninstalled.

    https://www.vbforums.com/showthread....E-Linker-AddIn

    Greetings
    sorry for using translator

  9. #9
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,068

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    I second using an add-in with the ability to execute a post compile command there are a couple.

    In FastBuild the command would be "regsvr32 /u /s %1"

    https://github.com/dzzie/addins/tree/master/FastBuild

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    I have discovered that unfortunately, regsvr32 /u does NOT remove all registry entries created by registering an ActiveX DLL. In particular, I used a program from NirSoft called RegFromApp that hooks the registry writing functions of programs. I used it to monitor the registry output of VB6 when registering an ActiveX DLL, so I could get a list of what needed to be removed to unregister the DLL.

    Then I ran regsvr32 to unregister the DLL, and then used RegEdit to manually check every registry key that RegFromApp had logged. Most, but NOT ALL of the keys were removed. There was one that remained, the AppID key and its associated registry values. The AppID key of my test ActiveX DLL is located at:
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{A0D0978D-80A5-46F7-AE35-7FDBAF28F97C}
    And it has 2 values (AppID and RunAs) which are also BOTH still existing. As it turns out, that GUID {A0D0978D-80A5-46F7-AE35-7FDBAF28F97C} which is in the name of that registry key, is actually the CLSID of Class1 of my test ActiveX DLL.

    This means if I'd had a bunch of public classes in my ActiveX DLL, I'd have a bunch of orphaned registry keys after unregistering the DLL. That is NOT a good outcome. Is there any program that's better than RegSvr32 that I could use that would actually seek out EVERY registry entry associated with an ActiveX DLL, and remove them all?


    Update:
    There is one good thing, and that is that after manually deleting this registry this registry entry, reregistering the component with regsvr32, does NOT add that registry key back in.
    Last edited by Ben321; Aug 13th, 2020 at 06:22 PM.

  11. #11
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,068

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    good find. You could run some kind of process monitor while you compile a dll and see if regsvr32 gets called or if its the IDE itself which registers it. The IDE might add extra reg keys during development to support IDE debugging , for some reason i think that fails in Win10 i cant remember now. Worst case use a native debugger or an api logger to watch new process and registry activity for the IDE while you compile a dll and see what the culprit is. Once you know exactly who is doing it then you could devise a plan, like writing a C hook dll in the IDE that rejects certain writes. Kind of a lot of work for the task but thats probably the only way to stop the IDE from doing what it wants.

    http://www.rohitab.com/apimonitor
    https://x64dbg.com/#start (has a 32bit version as well)

  12. #12
    Hyperactive Member
    Join Date
    Jun 2016
    Location
    EspaƱa
    Posts
    508

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    hi dz32
    very good complement I will try

    Greetings
    sorry for using translator

  13. #13
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    AppID contains DCOM entries for a compiled program unit. Normally these are only for an ActiveX EXE but might be included for a DLL to be invoked remotely, via RunDLL.exe, or from a 64-bit process.

    The entries are not typically made by the self-reg entrypoint logic that regsvr32.exe calls into. Most likely we get them created by VB6.exe as part of the make process.

    I suspect they get created on the dev machine to help Program Group development and debugging work in the IDE. The IDE probably inserts itself as a COM proxy between the client and the server (DLL).

  14. #14
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    Quote Originally Posted by Ben321 View Post
    That doesn't work. VB6 needs Windows XP compatibility activated for VB6.exe or it won't even run. Running any EXE in compatibility mode automatically gives it admin permissions.
    Actually no, I have not turned on any compatibly modes for VB6 on any OS and it works fine on all of them. It does need to be ran as admin but does not need xp compatibility mode.

  15. #15

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    I found one solution to this issue. I can compile my own program called Link.exe to be a proxy between vb6 and the real Link.exe. My proxy displays a textbox with the commandline that was issued from vb6 to Link.exe and allows editing of that commandline if needed. After clicking the X button in the upperright corner of the window of my proxy linker, in the Unload event, it calls the real linker with the command line (which may have been edited). The real linker has been renamed to LINK2.EXE (which is the name hardcoded into my proxy linker, and is what it will try to call so that MUST be the renamed name of the real linker), and my proxy is now called LINK.exe instead of Project1.exe (or whatever it was originally called).

    For the purpose of preventing VB6 from auto-registering an ActiveX DLL, you need to change the output filename in the proxy linker. VB6 already knows what the output DLL is going to be called, and as soon as it detects that this file exists it will register it. Just look for the commandline switch /OUT and change the filename name to anything else. Then close the proxy linker and the real linker will be called, and it will generate the DLL under the new filename. VB6 won't be able to find the DLL under the filename it expects, so it will pop up an error messagebox saying it couldn't find the DLL, and then it will cleanup the intermediate files by deleting the object files associated with the failed (but not actually failed) creation of the DLL. This error does NOT seem to cause any further bugs or destablizing of the VB6 IDE, so it seems to be a safe way to create an unregistered AXDLL.
    Last edited by Ben321; Aug 13th, 2020 at 07:30 PM.

  16. #16
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,068

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    nice

  17. #17
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,749

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    you can make a Standard DLL,start by "DLLMain()"

    and write vb code in "dllmain",if exe process is vb6.exe,so return 0,it will no register
    Code:
    Public Function DllMain(ByVal hInst As Long, ByVal fdwReason As Long, ByVal lpvReserved As Long) As Boolean
    Select Case fdwReason
    Case DLL_PROCESS_DETACH
       if process ="vb6.exe" then 
          DllMain=0
      end if
    Case DLL_PROCESS_ATTACH
    DllMain = True
    Case DLL_THREAD_ATTACH
    Case DLL_THREAD_DETACH
    End Select
    End Function

  18. #18
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,749

    Re: How do I make VB6 NOT automatically register ActiveX DLL that it compiles?

    I don't know what method you used in the end. Has my method been tested?

    I am the standard. Second, when I want to develop, he has to register com DLL every time, and then it crashes. That's why I came up with this idea. Strangely enough, after compiling, he would still execute the code in the VB project.

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