Old 3rd June 2004, 01:01   #1
brettg
Junior Member
 
Join Date: Jun 2004
Posts: 5
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
brettg is offline   Reply With Quote
Old 3rd June 2004, 02:32   #2
Vytautas
Major Dude
 
Vytautas's Avatar
 
Join Date: May 2003
Location: Victoria, Australia
Posts: 643
Send a message via ICQ to Vytautas
Check out the VB Runtime Install script for details as it uses this counter.

Vytautas
Vytautas is offline   Reply With Quote
Old 3rd June 2004, 04:29   #3
brettg
Junior Member
 
Join Date: Jun 2004
Posts: 5
I can't find this script in the Examples folder...can you give me the exact name of the .nsi file?
brettg is offline   Reply With Quote
Old 3rd June 2004, 04:38   #4
Vytautas
Major Dude
 
Vytautas's Avatar
 
Join Date: May 2003
Location: Victoria, Australia
Posts: 643
Send a message via ICQ to Vytautas
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
Vytautas is offline   Reply With Quote
Old 4th June 2004, 15:45   #5
[Ant]DiMension
Junior Member
 
Join Date: Mar 2003
Location: The Netherlands
Posts: 5
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)
code:
;------------------------
;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?
[Ant]DiMension is offline   Reply With Quote
Old 4th June 2004, 19:58   #6
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
UpgradeDLL does not handle the shared DLL user count. You should update the AddSharedDLL function.
Joost Verburg is offline   Reply With Quote
Old 6th June 2004, 10:08   #7
[Ant]DiMension
Junior Member
 
Join Date: Mar 2003
Location: The Netherlands
Posts: 5
code:
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!
[Ant]DiMension is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump