Jump to content
Sign in to follow this  
NicePerson

Register a dll

Recommended Posts

NicePerson

How to register a dll file with AutoIt?

For Example:

regsvr32 %windir%\system32\zipfldr.dll

Share this post


Link to post
Share on other sites
trancexx

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

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
NicePerson

Thanks trancexx it is better!

Share this post


Link to post
Share on other sites
NinjaDuck

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.