Skip to content
⌘ NSIS Forum Archive

Copy file - Register dll - Shared counter

10 posts

ACEMCP#

Copy file - Register dll - Shared counter

I tried to rewrite sunjammers code about "Upgrade a DLL" (http://nsis.sourceforge.net/archive/...instances=0,11)... His prg snippet is an macro, but I want to write Function if possible because I have to install lot of dll... I added more functionality, shared files counter handler from Add a shared DLL (http://nsis.sourceforge.net/archive/...instances=0,11)

First, I Push the parameters from the macro, then I pop the parameters, and do what I need from the function.

I am using this include file for this functionality:

[edited by kichik]attach large scripts. attached below 👎[/edit]

If I try to compile i got a next error message:
GetDLLVersionLocal: error reading version info from "$LOCALFILE"
!include: error in script: "Include\Installer.nsi" on line 52
Error in script "E:\Fejlesztes\ACE Mega CoDecS Pack\ACE Mega CoDecS Pack.nsi" on line 6 -- aborting creation process

I think error caused by $LOCALFILE variable, because If I remmark this line, the compiler stops next where $LOCALFILE appear...
What I did wrong?
Please help me!

Best regards,
ACEMCP
Joost Verburg#
I wrote that macro.

You are mising up run-time and compile time. GetDLLVersionLocal gets the version of a DLL on the compiler system (the DLL that will be included), so you can never use a run-time variable.

Always increasing the shared item count is also not a good idea. For example, it should not be increased when reinstalling.
kichik#
Do not copy and paste large scripts, attach them. This helps the forum stay clean and easy to read. The forum provides a vast database of questions and answers regarding NSIS, so it's important it stays clean and easy to read so users may easily find the answer they are looking for.
ACEMCP#
Sorry kichik!

Dear Joost!
Are there any way to solve this problem? I want to use this intelligent update feature for about 200 dlls. I think macro method makes the installer lot bigger.
How can I determine users run as installer or reinstaller? Enough to watch HKLM\Software\${PRODUCT} exist or there are another better sollution?
Joost Verburg#
Indeed, checking files or registry keys is a good solution.

You should use compile-time defines for GetDLLVersionLocal.
blayde#
Yeah, you could store it in the reg' and remove the entry at uninstall. you chould also check if the file(s) your installing already exist and need replacing.

eg
ACEMCP#
So I have to build dll table with define command like this:
!define aaadll aaa.dll
!define baadll baa.dll
etc
to add all the filename information to the script? Then I can use it compile time?Is it a right sollution? Or macro the whole Upgrade a DLL - at about 200 times?
ACEMCP#
Dear Joost!
I switched back to macro, because using function this are is an stupid move 😳)

I tried to add more functionality: Register dll, Shared counter

Register dll already implemented, but I may help for shared file counter:
there are a variable:
var INSTALLCOUNT

in the begening of installation:

ReadRegDWORD $INSTALLCOUNT HKLM "Software\${PRODUCT}" "Installer Counter" ; increase for every installation
; decreased every uninstallation
IntOp $INSTALLCOUNT $INSTALLCOUNT + 1
WriteRegDWORD HKLM "Software\${PRODUCT}" "Installer Counter" $INSTALLCOUNT

I increase every time,

(of course deinstallation remove at all)

When I installing files, I use this method
If file non exist shared dll counter be 1
If file exist but my program first installed (Installer Counter==1) shared dll counter Increased by 1
If file exist but my program already installed (Installer Counter>1) No increment.
If file exist and no (or 0) value of shared dll counter, the shared dll counter be 2.
Uninstall:
Uninstallation always decrease counter, and file and counter removed if reached 0...

This is the right sollution? Or you have better one?

ACEMCP
Joost Verburg#
For the shared DLL count, a separate function is available. You should also call it on a new installion (check whether installion files or registry keys exist).
ACEMCP#
But what is the matter if files exist but the file's sharedDLLs counter is 0 or non exist?