Jump to content

Register a dll


Recommended Posts

If you want to do that the way it should be done considering the language it would be:

#RequireAdmin


; Unregister
If _UnregisterServer("zipfldr.dll") Then
    MsgBox(64, "zipfldr.dll OK", "DllUnregisterServer succeeded!")
Else
    If @error = 1 Then
        MsgBox(48, "zipfldr.dll Error", "DllUnregisterServer failed with error code 0x" & Hex(@extended))
    Else
        MsgBox(48, "zipfldr.dll Error", "zipfldr.dll missing maybe?")
    EndIf
EndIf

; Register
If _RegisterServer("zipfldr.dll") Then
    MsgBox(64, "zipfldr.dll OK", "DllRegisterServer succeeded!")
Else
    If @error = 1 Then
        MsgBox(48, "zipfldr.dll Error", "DllRegisterServer failed with error code 0x" & Hex(@extended))
    Else
        MsgBox(48, "zipfldr.dll Error", "zipfldr.dll missing maybe?")
    EndIf
EndIf



; Functions...
Func _RegisterServer($sDll)
    Local $fInit, $fError
    Local $aCall = DllCall("ole32.dll", "long", "OleInitialize", "ptr", 0)
    If Not @error Then $fInit = $aCall[0] <> 1 ; The COM library is already initialized
    $aCall = DllCall($sDll, "long", "DllRegisterServer")
    If @error Then $fError = True
    If $fInit Then DllCall("ole32.dll", "none", "OleUninitialize")
    If $fError Then Return SetError(2, 0, False)
    Return SetError($aCall[0] <> 0, $aCall[0], $aCall[0] = 0)
EndFunc

Func _UnregisterServer($sDll)
    Local $fInit, $fError
    Local $aCall = DllCall("ole32.dll", "long", "OleInitialize", "ptr", 0)
    If Not @error Then $fInit = $aCall[0] <> 1 ; The COM library is already initialized
    $aCall = DllCall($sDll, "long", "DllUnregisterServer")
    If @error Then $fError = True
    If $fInit Then DllCall("ole32.dll", "none", "OleUninitialize")
    If $fError Then Return SetError(2, 0, False)
    Return SetError($aCall[0] <> 0, $aCall[0], $aCall[0] = 0)
EndFunc
Link to comment
Share on other sites

  • 2 years later...

What if the equivalent regsvr32.exe cmd line also calls DLLInstall or DLLUninstall (that is, there's a /i or /i:{command} on the regsvr32 cmdline)

Is that a nested autoit DLLCall or a separate one?

Usage: regsvr32 [/n] [/i[:cmdline]] dllname

/u - Unregister server

/s - Silent; display no message boxes

/i - Call DllInstall passing it an optional [cmdline]; when used with /u calls dll uninstall

/n - do not call DllRegisterServer; this option must be used with /i

Edited by Melba23
Enlarged font
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...