1

Is there a way in Java, or .NET or checking a registry key to see if a pdf viewer is installed?

A way to detect if there is a default pdf viewer is preferred, but checking if one is installed is fine also.

Thanks!

EDIT: To clarify, I am looking for a way of detecting if ANY PDF viewer is installed, or if there is a PDF viewer set as the default viewer, not necessarily Adobe Acrobat.

jhnclvr
  • 9,137
  • 5
  • 50
  • 55

2 Answers2

1

Check Adobe Reader is installed (C#)? shows what is the registry key that you have to check. It also provides C# code.

If you want to do this in java you have to access registry. There are several ways.

  1. run reg utility with appropriate parameters, read and parse its output.
  2. Use one of popular third party libraries that provide registry access API (Jawin, Jintegra, Jinterop etc)
  3. Use trick described here: http://alexradzin.blogspot.com/2011/01/access-windows-registry-with-pure-java.html
Community
  • 1
  • 1
AlexR
  • 114,158
  • 16
  • 130
  • 208
  • This is helpful, but not exactly what I am looking for. If they have another PDF viewer installed (like Sumatra PDF or something), this will not work. I am looking for something to see if Windows has a default program to open PDFs installed. Thanks! – jhnclvr Sep 14 '11 at 20:35
  • @jhnclvr, take a look on this article: http://vim.wikia.com/wiki/Windows_file_associations It explains how to create file associations in windows. Hopefully now you have all tools you need. – AlexR Sep 15 '11 at 09:07
0

You must find registry key which is refering default pdf viewer .HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExt\ may be key you are looking for.Inspect hive with regedit.exe .

ayengin
  • 1,606
  • 1
  • 22
  • 47