privatevoidbutton1_Click(objectsender,EventArgse)
{
if(checkAdobeReader()==true)
{
MessageBox.Show("有安裝AdobeReader");
}
else
{
MessageBox.Show("沒有安裝AdobeReader");
}
}
///<summary>
///確認是否有安裝AdobeReader
///</summary>
///<returns>true:有安裝,false:沒有安裝</returns>
privateboolcheckAdobeReader()
{
Microsoft.Win32.RegistryKeyuninstallNode=Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall");
foreach(stringsubKeyNameinuninstallNode.GetSubKeyNames())
{
Microsoft.Win32.RegistryKeysubKey=uninstallNode.OpenSubKey(subKeyName);
objectdisplayName=subKey.GetValue("DisplayName");
if(displayName!=null)
{
if(displayName.ToString().Contains("AdobeReader"))
{
returntrue;
//MessageBox.Show(displayName.ToString());
}
}
}
returnfalse;
}