By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

Detect Acrobat Reader

P: 19

Got a problem detecting if Acrobat Reader is installed on a machine, would really appreciate your help.

I've got a PDF Report that I export to a directory then open it with Acrobat Reader. I need to check if the PC has Acrobat Reader installed before I open it...

I found this code but it's not working, i always get the messagebox even if the PC has the software installed.

Expand|Select|Wrap|Line Numbers
  1. string RegPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
  2.             using (RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(RegPath))
  3.             {
  4.                 foreach (string SW_Name in RegKey.GetSubKeyNames())
  5.                 {
  6.                     if (SW_Name == "Acrobat Reader")
  7.                     {
  8.                         System.Diagnostics.Process.Start(@"C:\\...\\CK1_" + txtEntNo.Text + ".pdf");
  9.                     }
  10.                     else
  11.                     {
  12.                         MessageBox.Show("You do NOT have Acrobat Reader installed on your machine...", "No Acrobat Reader");
  13.                     }
  14.                 }
  15.             } 
The only other codes I could find online were JavaScript, i wanna do it in C#. I'm using WinForms!

Jan 15 '09 #1
Share this Question
Share on Google+
4 Replies

Expert 100+
P: 229
Open regedit and go to the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Cur rentVersion\Uninstall\" node. Then press Ctrl+F to search the subnodes for a string (e.g. "reader").

In my registry (I'm using Reader 8.0), it is saved under "{AC76BA86-7AD7-1033-7B44-A81000000003}", so that is what you should detect instead of "Acrobat Reader". Try other versions to see what the GUID looks like.

Other approach would be to go through all nodes in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Cur rentVersion\Uninstall\" and try to find the one where the DisplayName contains "Adobe Reader".

Additional note: it looks to me like your code is opening a MessageBox many times, once for each element of the loop. Change your code to check all nodes before deciding whether it is installed or not.
Jan 15 '09 #2

P: 19
Thanks a lot Vekipeki!
I just noticed now that my code pops up the message box for each element.. thanks once again, I'll try out your suggestions.
Jan 15 '09 #3

Expert 5K+
P: 7,872
Couldn't you just run this inside a try/catch block?
System.Diagnostics.Process.Start(@"C:\\...\\CK1_" + txtEntNo.Text + ".pdf");

If there was no handler for .PDF files, I think it throws an Exception?
Win32Exception: No application is associated with the specified file for this operation.

Might be a better way to do this, since not everyone will use Acrobat to read PDFs(like 99% will, but still)
Jan 15 '09 #4

P: 19
Thanks a lot Plater, I actually didn't think about doing it that way! It works perfectly!!!
Jan 16 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.