Wednesday, February 10, 2010

.Net Quick Tip: Programmatic Check if a PDF Reader is installed

image

A possibility to programmatically check in .Net (with C#) if a pdf-reader is installed:
[TestMethod]   
public void CheckPdfReaderAvailable()    
{    
	RegistryKey key = Registry.ClassesRoot.OpenSubKey(".pdf");    
	Assert.IsNotNull(key);    
}

Checking if Excel is installed can be achieved the following way:
[TestMethod]
public void CheckExcelAvailable()
{
    RegistryKey key = Registry.ClassesRoot.OpenSubKey("Excel.Application");
    Assert.IsNotNull(key);
}

1 comment:

  1. Thank you. Works. Also in Windows 2008 (x64).

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...