Reality-Loop

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

February 10, 2010 | 0 Minute Read
This post was originally posted on my old blog.

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);
}


http://www.google.com/s2/favicons?domain=twitter.com follow me on twitter, I need some friends :-)