cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jwhitwill
Level 3

Getting the reference count on files in a shared component

I understand that a reference count on some files is maintained in [HKEY_LOCAL_MACHINE]\SOFTWARE\Microsoft\Windows\Current Version\SharedDLLs

I've noted that only the files that happen to be in a subfolder of a folder referenced by my components are showing up in the list. Looking at the corresponding components in the component table I can see that they are the only ones that have a value other than null for their KeyPath field.
Files that are referenced directly (not in a subfolder) are not present in that SharedDLLs list and don't have anything in their KeyPath field.

This is peculiar to me because they must be reference counted somewhere (they are uninstalled at the correct time when the last package using them is removed). I need to be able to somehow acquire the reference count on these files in order to ensure that all my upgrade scenarios are covered correctly (to make a long story short).

If anyone can shed some light on where the reference count is maintained on components without a corresponding KeyPath value, it would be greatly appreciated.
Labels (1)
0 Kudos
(4) Replies
KathyMorey
Level 10

I'll assume you're using a Basic MSI, since you've referenced keypaths.

Windows Installer tracks components itself, by the GUID of the component. Files in a component are removed on uninstall if no other MSI has installed them, and if they have a zero reference count in the SharedDLLS key.

That key is actually a legacy entry to allow for applications that use a file but are not installed by Windows Installer. As I understand it, if you don't mark a component as "shared", Windows Installer doesn't increase the count for that key.
0 Kudos
jwhitwill
Level 3

Thank you very much for your reply.

You're correct in assuming this is a part of a "Basic MSI" project. The story behind it is we've distributed merge modules with shared components packaged in a couple different "Basic MSI" projects. We're releasing a new version which is a "minor upgrade" from the previous version. The issue is, I want to be able to warn the user if another package is using the old shared component.

I noted that you said it removes on uninstall "if no other MSI has installed them". Is there any way of determining this by using InstallScript?
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

There's always the MSI function call MsiEnumClients()...
0 Kudos
jwhitwill
Level 3

According to the description this appears to be what I'm looking for.

That function doesn't appear to be available inside installscript. Do I need to make this a different kind of custom action that resides in its own MSI dll?
0 Kudos