Solved

How to determine if a given program is installed?

Posted on 2006-06-26
7
161 Views
Last Modified: 2010-04-23
Generically, how can you tell if a given program is installed from within a VB.NET application/service/console?

Specifically, how can you tell if Adobe's Acrobat Reader is installed?
0
Comment
Question by:shadowfist1105
  • 4
  • 3
7 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 50 total points
Comment Utility
You can look in the Windows registry at HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader.

Bob
0
 

Author Comment

by:shadowfist1105
Comment Utility
Ok, how would you suggest that I Look in the Registry for this?  What class in .NET will let me look for that?
0
 

Author Comment

by:shadowfist1105
Comment Utility
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.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
What kind of answer were you looking for?

Bob
0
 

Author Comment

by:shadowfist1105
Comment Utility
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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\Windows\CurrentVersion\Uninstall"

    ' Look in the registry at the Uninstall location.
    Dim rootKey As Win32.RegistryKey = _
     Win32.Registry.LocalMachine.OpenSubKey(UNINSTALL)

    ' Create a structure big enough for all the key entries under Uninstall.
    Dim listSoftware As New SortedList(rootKey.SubKeyCount - 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("DisplayName") Then
          displayName = subKey.GetValue(valueName, "")

          Exit For
        End If

      Next valueName

      ' Add the display name to the list.
      listSoftware.Add(displayName, 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
0
 

Author Comment

by:shadowfist1105
Comment Utility
Thank you very much, that will help a great deal.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now