Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

Determine installed version of software

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim - 17 Jan 2008 14:08 GMT
I want to write a generic method to read the installed version of
software based on the exact software name that is displayed in Add /
Remove programs.  Is there a way to do this using C#?  I found a
method which will return all the installed software using this
registry key "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
and using System.Management.  I'm assuming I can use the same to get
what I need?

Thank you in advance for any help.

TK.
Lasse Vågsæther Karlsen - 17 Jan 2008 15:51 GMT
> I want to write a generic method to read the installed version of
> software based on the exact software name that is displayed in Add /
[quoted text clipped - 7 lines]
>
> TK.

Some examples of what you are seeing and what you want to do would
probably go a long way of helping us help you here.

Signature

Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3

Tim - 17 Jan 2008 16:15 GMT
I found a potential solution after a few hours of Google searching.
The code goes through the entire installed apps section in the
registery uninstall section.  The apps I'm looking for are displayed
by their product code in InstallShield.  I can pass in a string of the
exact app name and it will work even for those that are displayed by
product name using the displayName variable below.  Hope this helps
anyone else looking for this type of a solution.

Again, it needs to be tweaked slightly to pass in the app I'm looking
for return the string of the version that I looked for.  But it
appears to work.  Hopefully I'll meet my deadline:

       //Get all installed apps and version numbers
       public void GetInstalledApps()
       {
           string uninstallKey = (@"SOFTWARE\Microsoft\Windows
\CurrentVersion\Uninstall");
           string junk = "";
           string Version = @"SOFTWARE\Microsoft\Windows
\CurrentVersion\Uninstall";
           using (RegistryKey rk =
Registry.LocalMachine.OpenSubKey(uninstallKey))
           using (RegistryKey rv =
Registry.LocalMachine.OpenSubKey(Version))
           {
               string[] skNames = rk.GetSubKeyNames();
               int skNamesLen = skNames.Length;
               string skName = null;

               string[] svNames = rv.GetSubKeyNames();
               int svNamesLen = svNames.Length;
               string svName = null;

               for (int namesIdx = 0; namesIdx < skNamesLen; namesIdx+
+)//
               //    foreach (string skName in rk.GetSubKeyNames())
               {
                   skName = skNames[namesIdx];
                   svName = svNames[namesIdx];

                   using (RegistryKey sk = rk.OpenSubKey(skName))
                   {
                       sk.Name.Replace(uninstallKey, ""); //Root
                       object displayVersion = null, displayName =
null;

                       using (RegistryKey sv = rv.OpenSubKey(svName))
                       {
                           displayVersion =
sv.GetValue("DisplayVersion");
                           displayName = sv.GetValue("DisplayName");
                           if (displayVersion != null && displayName !
= null)
                           {
                               //displayValue = (+
+counter).ToString();
                               //TreeNode node = new
TreeNode(displayValue.ToString());
                               junk = displayVersion.ToString();
                               junk = displayName.ToString();
                               //nd1.Nodes.Add(node);
                           }
                       }
                   }
               }
           }
       }

TK.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.