Kbase P105664: 4GL/ABL: How to extract the Acrobat Reader command line from the Windows Registry and use it to open
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  26/11/2008 |
|
Status: Verified
GOAL:
4GL/ABL: How to extract the Acrobat Reader command line from the Windows Registry and use it to open a pdf file?
GOAL:
How to open a PDF file regardless of the Acrobat Reader version installed?
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
FIX:
The following sample Progress 4GL procedure uses the User Defined Function 'getAcrobatCommandLine' to extract the command line of the currently installed version of the Acrobat Reader and uses it in conjunction with the Windows WinExec API function to open a .pdf file:
/* The following Visual Style parameters define the initial state of the application's main window. */
&GLOBAL-DEFINE SW-SHOWNORMAL 1 /* Start the application in a normal size window. */
&GLOBAL-DEFINE SW-SHOWMINIMIZED 2 /* Start the application minimized. Show an icon at the bottom of the screen. */
&GLOBAL-DEFINE SW-SHOWMAXIMIZED 3 /* Start the application in a maximized window. */
&GLOBAL-DEFINE SW-SHOWNOACTIVATE 4 /* Start the application but set the focus back to the calling program. */
&GLOBAL-DEFINE SW-SHOWMINNOACTIVE 7 /* Start the application minimized and set the focus back to the calling program. */
DEFINE VARIABLE cProgramName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE iReturnResult AS INTEGER NO-UNDO.
FUNCTION getAcrobatCommandLine RETURNS CHARACTER () FORWARD.
ASSIGN
cProgramName = getAcrobatCommandLine()
cFileName = "C:\Program Files\Adobe\Acrobat 6.0\Help\ENU\Reader.pdf".
RUN WinExec (INPUT cProgramName + CHR(32) + cFileName , INPUT {&SW-SHOWNORMAL}, OUTPUT iReturnResult).
IF iReturnResult < 32 THEN
MESSAGE "Application Failed:" iReturnResult VIEW-AS ALERT-BOX.
FUNCTION getAcrobatCommandLine RETURNS CHARACTER ().
DEFINE VARIABLE cCmdLine AS CHARACTER.
LOAD "SOFTWARE" BASE-KEY "HKEY_LOCAL_MACHINE".
USE "SOFTWARE".
GET-KEY-VALUE SECTION "Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe"
KEY DEFAULT
VALUE cCmdLine.
UNLOAD "SOFTWARE".
RETURN cCmdLine.
END FUNCTION.
PROCEDURE WinExec EXTERNAL "KERNEL32.DLL":
DEFINE INPUT PARAMETER ProgramName AS CHARACTER.
DEFINE INPUT PARAMETER VisualStyle AS LONG.
DEFINE RETURN PARAMETER StatusCode AS LONG.
END PROCEDURE.