##=
# The variable $Bit will hold either 64 or 32 depending on system architecture
# This is used with ${Register::DLL} and ${UnRegister::DLL}
# Use this in the beginning of your code.
# This snippet should only be used once.
#
Var Bit
System::Call "kernel32::GetCurrentProcess()i.s"
System::Call "kernel32::IsWow64Process(is,*i.r0)"
StrCmpS $0 0 +3
StrCpy $Bit 64
Goto +2
StrCpy $Bit 32
#=#
#= UnRegister::DLL
#
# USAGE:
# ${UnRegister::DLL} "DLL Filename" /DISABLEFSR $0 $1
#
# ::DLL = Unregisters a DLL file.
# /DISABLEFSR = Disables redirection if x64. Use "" to skip.
# $0 = Return after call
# $1 = '' '' ''
#
!define UnRegister::DLL `!insertmacro _UnRegister::DLL`
!macro _UnRegister::DLL _DLL _FSR _ERR1 _ERR2
StrCmpS $Bit 64 0 +4
StrCmp ${_FSR} /DISABLEFSR 0 +3
ExecDos::Exec /TOSTACK /DISABLEFSR `"${REGSVR}" /s /u "${_DLL}"`
Goto +2
ExecDos::Exec /TOSTACK `"${REGSVR}" /s /u "${_DLL}"`
Pop ${_ERR1}
Pop ${_ERR2}
!macroend
##=
# Alternatively you can use this macro I found in my travels
# but be sure to include the x64 plugin as this macro makes
# use of it's function.
#
#= USAGE:
# ${UnregisterDLL} "SomeLibrary.dll"
#
!define UnregisterDLL "!insertmacro _UnregisterDLL"
!macro _UnregisterDLL _DLL
${If} ${RunningX64}
${DisableX64FSRedirection}
ExecWait '"$SYSDIR\regsvr32.exe" /s /u "${_DLL}"'
${EnableX64FSRedirection}
${Else}
UnRegDLL "${DLL}"
${EndIf}
!macroend
The /DISABLEFSR parameter should only be used on x64 machines. However, if you mess up there's a failsafe in the macros that will dodge this bullet for you.