*/ Opens a Registry key
DECLARE INTEGER RegOpenKey IN Win32API ;
Integer nHKey, String @cSubKey, Integer @nResult
*/ Sets a registry key. Also creates the entry if it does not exist
DECLARE INTEGER RegSetValueEx IN Win32API ;
Integer hKey, String lpszValueName, Integer dwReserved,;
Integer fdwType, String lpbData, Integer cbData
*/ Closes a Registry key
DECLARE INTEGER RegCloseKey IN Win32API INTEGER hKey
*/ Check if Windows is 64bit
DECLARE INTEGER IsWow64Process IN Win32API INTEGER hProcess, INTEGER @Wow64Process
DECLARE INTEGER GetCurrentProcess IN Win32API
CREATE CURSOR tmp(ref N(10), firstname C(20), lastname C(20))
SELECT "tmp"
APPEND BLANK
REPLACE tmp.ref WITH 1, tmp.firstname WITH "Mickey", tmp.lastname WITH "Mouse"
APPEND BLANK
REPLACE tmp.ref WITH 2, tmp.firstname WITH "Donald", tmp.lastname WITH "Duck"
APPEND BLANK
REPLACE tmp.ref WITH 3, tmp.firstname WITH "Scrooge", tmp.lastname WITH "McDuck"
*/ For the example printing to work you need to create a report and save it as "c:\temp\report1.frx".
*/ The report itself can just have fields tmp.ref, tmp.firstname, tmp.lastname.
*/ Note that the function adobe_init has to called each time the report is run. This is necessary because
*/ after printing, Acrobat clears the Registry entry set by adobe_init.
SET PRINTER TO NAME "ADOBE PDF"
=adobe_init("c:\temp\Mickey.pdf")
REPORT FORM "c:\temp\report1.frx" FOR tmp.ref = 1 NOCONSOLE TO PRINTER
SET PRINTER TO NAME "ADOBE PDF"
=adobe_init("c:\temp\Donald.pdf")
REPORT FORM "c:\temp\report1.frx" FOR tmp.ref = 2 NOCONSOLE TO PRINTER
SET PRINTER TO NAME "ADOBE PDF"
=adobe_init("c:\temp\Scrooge.pdf")
REPORT FORM "c:\temp\report1.frx" FOR tmp.ref = 3 NOCONSOLE TO PRINTER
*-----------------------------------------------------------------------------------
FUNCTION adobe_init
*/ In the "Adobe PDF" printer driver properties you must also set :
*/ - Spool print documents so program finishes printing faster
*/ - Start printing after last page is spooled
*/ - Print spooled documents first
LPARAMETERS lcFilePathAndName
LOCAL lnKeyRef, lcRegPath, lcExePathAndName, lnWin64
lnKeyRef = 0
lcRegPath = "Software\Adobe\Acrobat Distiller\PrinterJobControl"
lnWin64 = 0
=IsWow64Process( GetCurrentProcess(), @lnWin64)
*/ In Windows x86 we have to set the calling .exe file path and name in PrinterJobControl.
*/ The .exe name and path will vary depending on the application.
*/ If the application doing the printing is 32 bit and running on Windows 64 bit then we have to
*/ always set the calling .exe file path and name as "C:\Windows\splwow64.exe" in PrinterJobControl.
*/ Should Windows be installed to a different folder then change "C:\Windows\" as appropriate!
IF lnWin64 = 0
lcExePathAndName = HOME()+"vfp9.exe"
ELSE
lcExePathAndName = "C:\Windows\splwow64.exe"
ENDIF
RegOpenKey(2147483649,lcRegPath,@lnKeyRef)
RegSetValueEx(lnKeyRef,lcExePathAndName,0,1,lcFilePathAndName,LEN(lcFilePathAndName))
*/ Close the registry key
RegCloseKey(2147483649)
ENDFUNC