shadowfist1105
asked on
How to determine if a given program is installed?
Generically, how can you tell if a given program is installed from within a VB.NET application/service/consol e?
Specifically, how can you tell if Adobe's Acrobat Reader is installed?
Specifically, how can you tell if Adobe's Acrobat Reader is installed?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nevermind, I just found some old code that access the registry for a service (gives it a description).
Thanks, not exactly the type of answer i was looking for, but it will work.
Thanks, not exactly the type of answer i was looking for, but it will work.
What kind of answer were you looking for?
Bob
Bob
ASKER
well, one that didn't involve looking in the registry for something that might be installed with that specific verbage. One that would use a class like System.Diagnostics.Process (obviously not that one). It doesn't matter that much, I just hate the registry.
Thank you for your time.
Thank you for your time.
The Process class can only find references to running programs, and not installed ones.
Here is a class from my bag-o-tricks:
Imports Win32 = Microsoft.Win32
Public Class InstalledSoftware
Public Shared Function GetList() As SortedList
Const UNINSTALL$ = "SOFTWARE\Microsoft\Window s\CurrentV ersion\Uni nstall"
' Look in the registry at the Uninstall location.
Dim rootKey As Win32.RegistryKey = _
Win32.Registry.LocalMachin e.OpenSubK ey(UNINSTA LL)
' Create a structure big enough for all the key entries under Uninstall.
Dim listSoftware As New SortedList(rootKey.SubKeyC ount - 1)
' Look through all the keys for the 'DisplayName' value.
' If 'DisplayName' not found, then just use the key name for
' the display name.
For Each keyName As String In rootKey.GetSubKeyNames
' Get all sub-keys under Uninstall.
Dim subKey As Win32.RegistryKey = rootKey.OpenSubKey(keyName )
' Start by using the key name as the display name.
Dim displayName As String = keyName
' Look for the 'DisplayName' value, and use that name,
' if found.
For Each valueName As String In subKey.GetValueNames
If valueName.Equals("DisplayN ame") Then
displayName = subKey.GetValue(valueName, "")
Exit For
End If
Next valueName
' Add the display name to the list.
listSoftware.Add(displayNa me, displayName)
Next keyName
' Return the sorted list to the caller.
Return listSoftware
End Function
End Class
Example usage:
Dim list As SortedList = InstalledSoftware.GetList( )
Bob
Here is a class from my bag-o-tricks:
Imports Win32 = Microsoft.Win32
Public Class InstalledSoftware
Public Shared Function GetList() As SortedList
Const UNINSTALL$ = "SOFTWARE\Microsoft\Window
' Look in the registry at the Uninstall location.
Dim rootKey As Win32.RegistryKey = _
Win32.Registry.LocalMachin
' Create a structure big enough for all the key entries under Uninstall.
Dim listSoftware As New SortedList(rootKey.SubKeyC
' Look through all the keys for the 'DisplayName' value.
' If 'DisplayName' not found, then just use the key name for
' the display name.
For Each keyName As String In rootKey.GetSubKeyNames
' Get all sub-keys under Uninstall.
Dim subKey As Win32.RegistryKey = rootKey.OpenSubKey(keyName
' Start by using the key name as the display name.
Dim displayName As String = keyName
' Look for the 'DisplayName' value, and use that name,
' if found.
For Each valueName As String In subKey.GetValueNames
If valueName.Equals("DisplayN
displayName = subKey.GetValue(valueName,
Exit For
End If
Next valueName
' Add the display name to the list.
listSoftware.Add(displayNa
Next keyName
' Return the sorted list to the caller.
Return listSoftware
End Function
End Class
Example usage:
Dim list As SortedList = InstalledSoftware.GetList(
Bob
ASKER
Thank you very much, that will help a great deal.
ASKER