Cyberiafreak

"Fortunate are those who take the first steps.” ― Paulo Coelho

C# Tips #2 [How to get the list of softwares installed from Registry]

RegKey
Code Snippet: Checking the Registry Key

       
private void Form1_Load(object sender,EventArgs e)

       
{

           
Microsoft.Win32.RegistryKey
rgKey;

           
rgKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");

           
string[]
strListOfSoftwareKeys = rgKey.GetSubKeyNames();

           
bool blFlag = false;

           
foreach(string strEntry in strListOfSoftwareKeys)

           
{

               
if(strEntry=="YOUR
Application")

               
{

                   
blFlag = true;

                   
MessageBox.Show("Yes installed already ");

                   
return;

               
}

               
else

               
{

                   
blFlag = false;

               
}

           
}

           
if(!blFlag)

               
MessageBox.Show("Please install it and then
try.."
);  

        }

Applicable Scenario

(1)     To get the list of installed application from registry

(2)  To check if it’s a licensed or not, by reading the keys
written during registration. May be old technique but still works for reason.

(3)  During .NET installation we may need to look for some of the third
party application like Acr.reader, MS office etc..

Advertisements

July 3, 2007 - Posted by | Uncategorized

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: