Archive: Active X Installation


Can someone show me the code they use to update an active x dll?

Handling needing a re-boot etc.

Cheers.


hi mike,

you could do it like this: (untested)

Function RegisterActiveX

StrCpy $0 "to_be_upd.dll"
StrCpy $1 "new.dll"

CompareDLLVersions $0 $1 lbl_end lbl_upd

lbl_upd:
UnRegDLL $0
File $1
RegDLL $1

lbl_end:
nop;

FunctionEnd

cu yzo


Uh-oh. Do you need to UnReg it first !?!?!
(O MY GOD!)
And shouldn't you check if the file already exists? If it doesn't, does CompareDLLVersions go to the right spot?


hi,

whops .. sure.
like i said .. untested :)

maybe it is better like this: (still untested)

Function RegisterActiveX

StrCpy $0 "to_be_upd.dll"
StrCpy $1 "new.dll"

IfFileExists $0 lbl_compare lbl_end

lbl_compare:
CompareDLLVersions $0 $1 lbl_end lbl_upd
;goto lbl_end if versions are
;the same or an error occures(?)
GoTo lbl_end

lbl_upd:
;UnRegDLL $0 ;is that ok, dunno.
File $1
RegDLL $1

lbl_end:
nop;

FunctionEnd

cu yzo


It's really simple ... if you want to update 'whatever.dll' and you keep your copy in 'C:\Distrib' when you are building your NSIS executable:

CompareDLLVersions /STOREFROM "$SYSDIR\whatever.dll" "C:\Distrib\whatever.dll" lblSkip lblCopy
lblCopy:
File /ONAME="$SYSDIR\whatever.dll" "C:\Distrib\whatever.dll"
RegDll "$SYSDIR\whatever.dll"
lblSkip:
Nop

This works because CompareDLLVersions continues without a goto if the target DLL doesn't exist. And the best part is that it works without changing the current output directory.

The only time you need to UnReg is when you remove a DLL, not update it to a new version.


Oh, the File command automatically handles the copy-on-reboot thing. It's the default, if I remember right. Just add a message at the end of the installer saying "You may have to reboot before XXXXX will work correctly." Someday Justin will add reboot prompting support and then you won't even need that :p


Ok you can't do:


File /oname="$SYSDIR\whatever.dll" c:\distrib\whatever.dll

it is

SetOutPath $SYSDIR
File /oname="whatever.dll" c:\distrib\whatever.dll


or MakeNSIS pukes.

Is this behaviour of file documented? I can't find anymention of that...

Oh Dear.

I spoke to justin. File doesn't handle anything to do with re-booting. Bum.


Hrm...

I lost my copy of the code in a HD crash last week, but from what I remember, File *does* have support for using 'wininit.ini' to copy files on reboot. It just doesn't tell you if you need to reboot or not.

That is, unless Justin changed it, or I misread the code. Both are highly possible.