Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Registering Dlls programatically (VB6)

    Im trying to register dll's programatically, however so far i've only been able to find examples written in C, or examples where you need to know the name of the dll at design time.

    I want to be able to pass a dll/ocx with its path to a function which will then register/unregister it (depending on what I specify) and have a return code if it fails, i.e. the example I saw in C returned a -3 when the user ran it and he was then told that the -3 meant the file was in use.

    Alternatively, if anyone knows where I can download a dll that already does this could you post the link (it doesnt have to be a free dll).

    Any help would be much appreciated as im this ' ' close to giving it up as a bad job and using regsvr32 in silent mode and ignoring the errors completely - but that would be completely unprofessional of me!

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Registering Dlls programatically (VB6)

    Phil

    Creating a package with the Package and Deployment wizard, will register any dependent dll's or ocx's.
    Just creating an EXE won't.

    I use coding in my project of a known local location, to copy the library or control and then register it programatically as below.
    But, if I create a distributable package, the code is not required because any dependencies are automatically registered.
    Although I copy my control to the local folder, this code registers each time the EXE is run , hence I dropped it out of my project.

    <pre> 'Copy MSMAPI32.ocx File
    If Dir(strLocalFolder & "MSMAPI32.ocx") = "" Then
    FileCopy "D:UtilitiesMSMAPI32.ocx", strLocalFolder & "MSMAPI32.ocx"
    'strLocalFolder is C:MM-Utilities
    End If</pre>




    <pre>'Register It
    Shell ("C:MM-Utilitiesregsvr32.exe /s MSMAPI32.ocx")</pre>


  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Registering Dlls programatically (VB6)

    Thanks for your reply but I think you missed my point.

    Firstly, I was under the impression using regsvr32 either gave a message box or no error at all if running in silent. Due to the nature of the program I need to put the error message in a caption on a form so I need to be able to actually capture the error code if there is one.

    Secondly, im not using the deployment wizard. My program is an update program which downloads files from our FTP site when they are updated (similar to norton live update if you want a comparison).

    The user installs our program using the installshield application I have created.
    The updater then is used to update existing files and possibly add new files.
    Where a dll is concerned, it is entirely possible something could happen while running the app, so I'd prefer to un-register the current dll, archive it, copy over the new dll then register it.

    This method does produce a few issues regarding uninstalling the product, but we already have such issues which wont be resolved in the near future, so adding to them wont hurt!
    In an ideal world i'd create update files using installshield and have them so they can be run from the web, but I had to wing it when creating the installer as it was, so i'll definately need a few courses in installshield before tackling the update scenario! Unfortunately, there just isnt time at the moment.

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Registering Dlls programatically (VB6)

    Sorry I couldn't help Phil, and I don't have a Dodge Viper either <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  5. #5
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Registering Dlls programatically (VB6)

    Edited by <!profile=StuartR>StuartR<!/profile> to make link active - see <!help=19>Help 19<!/help>

    No probs Dave thanks all the same though. Bit of a weird one to explain! However, i've been given the following link which im just testing now:
    http://www.codeguru.com/vb/controls/vb_act...icle.php/c3479/

    As for the Viper, i'm still hoping for that elusive lottery win!

  6. #6
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Registering Dlls programatically (VB6)

    Don't know if you got this sorted out yet, but if interested see attached text file, demonstrates one way to register COM components (.DLL, .OCX) w/o relying on RegSvr32.exe and w/o having to "hard code" the API function declarations for DllRegisterServer and DllUnregisterServer, which RegSvr32 calls from the file being registered (all inprocess COM servers are "required" to export these two functions for self-registration purposes). See RegisterDLL function, which can be used for both registering & unregistering component. The function returns zero on success, or an error code (WIN32 or user-defined constant) which may be helpful in troubleshooting errors. Note that I had to resort to some user-defined errors because if you check the MSDN documentation for DllRegisterServer (some excerpts included in attached file), upon error the function can return several error codes, some general, some specific such as SELFREG_E_TYPELIB and SELFREG_E_CLASS - but if you look these up in the applicable C++ header file (OLECTL.H) (they aren't found in the standard WIN32API.TXT file) the DEFINE statements make use of the C++ MAKE_SCODE macro to define value (no relation to a VBA macro!) - and I am not sure of how to translate this type of #DEFINE to a VB CONST declaration (and am too lazy to look it up in some incomprehensible C++ text). So simply used a user-defined error constant if call to DllRegisterServer failed. Note also, to avoid "hard-coding", use of GetProcAddress to get function address in target DLL, and CallWindowProc to call function "indirectly". This code worked OK on my system (VB/VBA 6.0, WIN XP).

    HTH

  7. The Following User Says Thank You to MarkD For This Useful Post:

    neotussanonis (2015-10-14)

  8. #7
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Registering Dlls programatically (VB6)

    Thanks for the file Mark. I have found a solution (the link in my last post) but havent tested it yet, so if it doesnt work i'll give you're code a go.

  9. #8
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Registering Dlls programatically (VB6)

    Here's a little VB project from a while back. The specific code you want is in Module1.bas. (You'll need to comment out the messages in there). Of all the little VB utilities I have written, I use this the most, since a lot of my development time is spent in ASP with VB .dll's, I get to reregister new .dll's on various IIS servers WAY too frequently! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

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