Archive: Shared DLLs usage count


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


Check out the VB Runtime Install script for details as it uses this counter.

Vytautas


I can't find this script in the Examples folder...can you give me the exact name of the .nsi file?


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


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?

UpgradeDLL does not handle the shared DLL user count. You should update the AddSharedDLL function.


 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!