brettg
3rd June 2004 02:01 UTC
Shared DLLs usage count
I would to know if there is a way to automatically handle usage counting for shared DLLs. As you must know, Windows has a mechanism to keep count of shared DLLs, so that setup programs can know when to unregister and delete the shared DLL. I can't find any info on it.
thanks for any help
Vytautas
3rd June 2004 03:32 UTC
Check out the VB Runtime Install script for details as it uses this counter.
Vytautas
brettg
3rd June 2004 05:29 UTC
I can't find this script in the Examples folder...can you give me the exact name of the .nsi file?
Vytautas
3rd June 2004 05:38 UTC
I think that it's available in the NSIS Archive on the net. However you can also read the two articles in the NSIS Help file. Appendixes B9 and B10
Vytautas
[Ant]DiMension
4th June 2004 16:45 UTC
I'm using this script with some succes. Only, Microsoft recommends increasing Shared DLL count to 1 if the file is already present on the system, so that programs that didn't correctly increase DLL count still work after the user uninstalls your application.
I've tried implementing this in the UpgradeDLL macro in the following way: (last four lines are by me)
;------------------------
;Check file and version
IfFileExists $R4 0 upgradedll.copy_${UPGRADEDLL_UNIQUE}
ReadRegDword $1 HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R4
StrCmp $1 "" 0 +3
Push $R4
Call AddSharedDLL
Only this one seems to have some flaws. Can anyone spot what is going wrong?
Joost Verburg
4th June 2004 20:58 UTC
UpgradeDLL does not handle the shared DLL user count. You should update the AddSharedDLL function.
[Ant]DiMension
6th June 2004 11:08 UTC
Function AddSharedDLL
Exch $R1
Push $R0
ReadRegDword $R0 HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1
StrCmp $R0 "" increment
IntOp $R0 $R0 + 1
WriteRegDWORD HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 $R0
Goto noincrement
increment:
IfFileExists $R1 0 noincrement
WriteRegDWORD HKLM Software\Microsoft\Windows\CurrentVersion\SharedDLLs $R1 2
noincrement:
Pop $R0
Pop $R1
FunctionEnd
This seems to work perfectly. Thanks!