Consultor Eletrônico



Kbase P14886: How to open a file or URL with its associated program on Windows using the function ShellExecuteA wi
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Verified

GOAL:

How to launch the associated application of a file from within 4GL

GOAL:

How to locate and launch an application from within 4GL

GOAL:

How to open a file or URL with its associated program on Windows

GOAL:

Using ShellExecute to launch application from within Progress

FACT(s) (Environment):

Progress 8.x
Progress 9.x
OpenEdge 10.x
Windows

FIX:

This Solution shows sample 4GL statements to open a file or URL using its associated program. It uses the Windows function ShellExecuteA within the SHELL32.DLL
DEFINE VARIABLE hInstance AS INTEGER.

DEF BUTTON b-ok.
FORM b-ok WITH FRAME zz.

ON CHOOSE OF b-ok DO:
RUN ShellExecuteA(0, "open", "http://www.progress.com/", "", "", 0, OUTPUT hInstance).
END.

UPDATE b-ok WITH FRAME zz.

PROCEDURE ShellExecuteA EXTERNAL "shell32.dll":
DEFINE INPUT PARAMETER hwnd AS LONG. /* Handle to parent window */
DEFINE INPUT PARAMETER lpOperation AS CHAR. /* Operation to perform: open, print */
DEFINE INPUT PARAMETER lpFile AS CHAR. /* Document or executable name */
DEFINE INPUT PARAMETER lpParameters AS CHAR. /* Command line parameters to executable in lpFile */
DEFINE INPUT PARAMETER lpDirectory AS CHAR. /* Default directory */
DEFINE INPUT PARAMETER nShowCmd AS LONG. /* Whether shown when opened:
0 hidden, 1 normal, minimized 2, maximized 3,
0 if lpFile is a document */
DEFINE RETURN PARAMETER hInstance AS LONG. /* Less than or equal to 32 */
END.