Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to determine if Acrobat or Acrobat Pro is installed



Permlink Replies: 6 - Last Post: Aug 22, 2016 1:43 PM Last Post By: S De Threads: [ Previous | Next ]
S De

Posts: 16
Registered: 5/1/15
How to determine if Acrobat or Acrobat Pro is installed
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 12:43 PM
In my application we have a pdf help file. I launch it to appropriate places using ShellExecute and named destinations. A problem I'd like to resolve though is how I can determine if the machine has acrobat reader installed (in which case I should call ShellExecute with the program AcroRd32.exe) or acrobat pro installed (in which I should call ShellExecute with the program Acrobat.exe). Any suggestions?
Clement Doss

Posts: 76
Registered: 3/26/00
Re: How to determine if Acrobat or Acrobat Pro is installed
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 3:11 PM   in response to: S De in response to: S De
What if the user has another PDF reader?
I always try to use the default application for the extension.
Ex:
ShellExecute(handle,'open','C:\somepath\somefile.pdf', '','',SW_SHOWNORMAL);

This way the default PDF reader will be called. You can use this same call to open other default extensions like .doc, .xlsx, etc.

HTH,
Clément
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How to determine if Acrobat or Acrobat Pro is installed
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 4:01 PM   in response to: Clement Doss in response to: Clement Doss
Clement wrote:

ShellExecute(handle,'open','C:\somepath\somefile.pdf', '','',SW_SHOWNORMAL);

Typically, if you want the registered app to perform its default action
on the file, you should use nil instead of 'open' for the verb.

ShellExecute(handle, nil, ...);


Not all apps use 'open' by default.

--
Remy Lebeau (TeamB)
S De

Posts: 16
Registered: 5/1/15
Re: How to determine if Acrobat or Acrobat Pro is installed
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 19, 2016 1:46 PM   in response to: S De in response to: S De
Okay, so maybe I'm going about this the wrong way, but the reason I was doing it by calling the program is that I need to pass it parameters. For example,

ShellExecute(self.Handle, nil, AcroRd32.exe, '/n /A "nameddest = Maps&pagemode=bookmards&xoom=100&toolbar=1&statusbar=1&messages=0&navpages=1" "..\Help.pdf", nil, SW_SHOWMaximized);

If instead I try to put '..\Help.pdf' in place of AcroRd32.exe, how would I still have the parameters I need to open a new instance of the pdf at the correct named destination and with the other properties set?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How to determine if Acrobat or Acrobat Pro is installed
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 19, 2016 3:04 PM   in response to: S De in response to: S De
S wrote:

If instead I try to put '..\Help.pdf' in place of AcroRd32.exe, how
would I still have the parameters I need to open a new instance
of the pdf at the correct named destination and with the other
properties set?

One option might be like this:

ShellExecute(Self.Handle, nil, 'Path\To\Help.pdf', '/n /A "nameddest = Maps&pagemode=bookmards&xoom=100&toolbar=1&statusbar=1&messages=0&navpages=1"', 
nil, SW_SHOWMAXIMIZED);


Alternatively, you can pass the PDF filename to FindExecutable() to get the
EXE path of the app that handles PDF files, and then pass that EXE path to
ShellExecute() (or better, CreateProcess()) with your relevant parameters,
like you were before:

var AppPath: array[0..MAX_PATH] of Char;
FindExecutable('Path\To\Help.pdf', nil, AppPath);
ShellExecute(Self.Handle, nil, AppPath, '/n /A "nameddest = Maps&pagemode=bookmards&xoom=100&toolbar=1&statusbar=1&messages=0&navpages=1" 
"Path\To\Help.pdf"', nil, SW_SHOWMAXIMIZED);


However, keep in mind that neither of these approaches know which kind of
app is registered to handle PDFs. If the user has some PDF app other than
AcroBat installed, these parameters are likely to not work. If you need
to handle AcroBat specifically, check if it stores its installation path
in the Registry somewhere, such as under "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths".

--
Remy Lebeau (TeamB)
Tim Frost

Posts: 21
Registered: 11/21/99
Re: How to determine if Acrobat or Acrobat Pro is installed
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 20, 2016 6:10 AM   in response to: S De in response to: S De
Any suggestions?

Go to HLKM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ and
look for keys AcroRd32.exe or Acrobat.exe. The default value of this
key will be the path to the EXE (if the EXE is installed). I do not
know whether the key is deleted if the application has been uninstalled.
S De

Posts: 16
Registered: 5/1/15
Re: How to determine if Acrobat or Acrobat Pro is installed
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 22, 2016 1:43 PM   in response to: S De in response to: S De
Thanks @Remy Lebeau (TeamB)! The first option does not work. I actually tried that and then posted. But the FindExecutable was exactly what I needed. Our program is internal to the company and all employees have either Acrobat Reader or Pro installed on their machines so I really don't need to worry about other pdf readers.

Thanks all for your help!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02