Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can VFP determine version of Adobe

Status
Not open for further replies.

michaelkatz

Programmer
Sep 1, 2002
50
GB
I have an application that prints PDF files. If the user has Acrobat Professional installed, I can do it transparently using the coding in chapter 8 of MegaFox by Hertzenwerke Publishing.

The only way I can do it if the user has only the Acrobat Reader installed is by using ShellExecute.

1. Is there a better way to do this ?

2. Is ther a way to determine which version of Acrobat is installed ?

Thanks,
Michael
 
Using Shellexecute to print a pdf should work for any of the versions - the key here may be "transparently" as you stated. Can you be more specific? Does it work for older versions?

Take a look at my entry in the thread: Thread184-243825

It uses the shellexecute to launch a hyperlink, but it could be used to print a pdf as well.

If you still need to know the version, open the windows registry on the different computers & look at the localmachine/software keys. Find Adobe & drill down. You should see a verson tag and be able to determine the values for each. I think there are one or more FAQs on reading the registry that can assist you once you determined how Adobe stores their versioning info.



Jim Osieczonek
Delta Business Group, LLC
 

Geoff

According to the help file, AGETFILEVERSION() returns an array of programs and DLL written in FoxPro. The poster requires the version of Adobe Acrobat.


Creates an array containing information about files with Windows version resources such as .exe, .dll, and .fll files, or automation servers created in Visual FoxPro

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Retrieving information from the Registry is a good way that's what it was created for. I'm not sure which of these methods is more reliable for future Acrobat releases. I have not tested this AGETFILEVERSION() function on other Windows such as WinXP, only in Win2k. Trying the following code, element 11, showed the version.

Code:
lcFileName = "C:\WINNT\system32\LzExpand.dll"
lnRows = AGETFILEVERSION(laArrayName, lcFileName)
DISPLAY MEMORY LIKE laArrayName

lcFileName = "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe"
lnRows = AGETFILEVERSION(laArrayName, lcFileName)
DISPLAY MEMORY LIKE laArrayName

In the quote from the *excellent* Vfp-Help file, can be interpreted more than one way. I guess the emphasis should be on "Windows version resources". such as the ones listed and/or *including* VFP COM/automation servers.

Creates an array containing information about files with Windows version resources such as .exe, .dll, and .fll files, or automation servers created in Visual FoxPro.
At one time I thought of becoming a Lawyer, but ended up in Visual FoxPro.




 
Michael,

I agree with Jim. ShellExecute() doesn't know or care which application or version is installed. Provided the PDF extension has an associated application, ShellExecute() will open the file. That's the whole point of it.

I also agree with Geoff when he says that AGETFILEVERSION() is not restricted to VFP files. In my experience, it works with any executable that has embedded version information.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hi Michael.,

Which code in my chapter of MegaFox are you referring to to print the PDF? This code should work as well:

You pass three parameters - the file name, the folder it is in, and "Print".

Code:
* WinApi :: ShellExecute
*  Function: Opens a file in the application 
*            that it's associated with.
*      Pass: lcFileName -  Name of the file to open
*   
*  Return:   2  - Bad Association (ie, invalid URL)
*            31 - No application association
*            29 - Failure to load application
*            30 - Application is busy 
*
*            Values over 32 indicate success
*            and return an instance handle for
*            the application started (the browser)
LPARAMETERS tcFileName, tcWorkDir, tcOperation

LOCAL lcFileName, ;
      lcWorkDir, ;
      lcOperation

IF EMPTY(tcFileName)
   RETURN -1
ENDIF

lcFileName  = ALLTRIM(tcFileName)
lcWorkDir   = IIF(TYPE("tcWorkDir") = "C", ;
                       ALLTRIM(tcWorkDir),"")
lcOperation = IIF(TYPE("tcOperation")="C" AND ;
                  NOT  EMPTY(tcOperation), ;
                  ALLTRIM(tcOperation),"Open")

* ShellExecute(hwnd, lpszOp, lpszFile, lpszParams,;
*              lpszDir, wShowCmd)
* 
* HWND hwnd - handle of parent window
* LPCTSTR lpszOp    - address of string for 
*                     operation to perform
* LPCTSTR lpszFile  - address of string for filename
* LPTSTR lpszParams - address of string for 
*                     executable-file parameters
* LPCTSTR lpszDir   - address of string for default
*                     directory
* INT wShowCmd      - whether file is shown when
*                     opened
DECLARE INTEGER ShellExecute ;
       IN SHELL32.DLL ;
       INTEGER nWinHandle,;
       STRING cOperation,;   
       STRING cFileName,;
       STRING cParameters,;
       STRING cDirectory,;
       INTEGER nShowWindow

RETURN ShellExecute(0,lcOperation,lcFilename,;
                    "",lcWorkDir,1)

*: EOF :*

BTW, thanks for buying Megafox!

_RAS
VFP MVP
 
The "code" I am referring to is really the form PdfDisplay5a.

I call it as follows:

* * * * * * * * *
DO FORM frmPDFFiles ;
NAME m.loForm LINKED ;
WITH &xTOPDF ;
NOSHOW

IF VARTYPE( m.loForm ) = "O"
m.llTested = m.loForm.PrintPDF()
ELSE
=MESSAGEBOX("Problem creating the form.")
ENDIF
* * * * * * * * *

The NOSHOW parameter keeps it transparent.

If I have Acrobat Reader open I get a file not found error from the Reader; otherwise, the application uses Acrobat Professional ( by Default ) and works fine.

So I decided to use ShellExecute for installations with Reader and your form for Acrobat professional installations.

Once it is installed on the user machine, I would like to figure out which version o Acrobat will available.

Thanks for any help.
 
Geoff

I've used it on Win 98, 2000, and XP on all sorts of Exes and DLLs. It's certainly not restricted to files created by Fox.

Sorry, I was only quoting the FoxPro helpfile.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top