Kbase 18875: How to Call WIN32 API Function: FindExecutable
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  6/1/1999 |
|
How to Call WIN32 API Function: FindExecutable
DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.
INTRODUCTION:
=============
The following sample code shows how to call the Win32 API function
called FindExecutable. This function finds the name of the program
that is associated with a specified file. The Windows registration
editor can be used to associate type of files with particular
applications.
This code has been tested on Windows NT 4.0 Workstation only.
DEFINE VARIABLE chrFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE chrDirectory AS CHARACTER NO-UNDO.
DEFINE VARIABLE chrResult AS CHARACTER NO-UNDO.
DEFINE VARIABLE intRC AS INTEGER NO-UNDO.
PROCEDURE FindExecutableA EXTERNAL 'SHELL32.DLL':
DEFINE INPUT PARAMETER chrFile AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER chrDirectory AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER chrResult AS CHARACTER NO-UNDO.
DEFINE RETURN PARAMETER intRC AS LONG NO-UNDO.
END PROCEDURE.
ASSIGN chrFile = 'C:\Temp\SomeFile.Txt'
chrResult = FILL(' ', 255).
RUN FindExecutableA(INPUT chrFile,
INPUT chrDirectory,
INPUT-OUTPUT chrResult,
OUTPUT intRC).
IF intRC > 32 THEN
MESSAGE 'Executable Name = ' TRIM(chrResult) VIEW-AS ALERT-BOX.
ELSE
IF intRC = 31 THEN
MESSAGE 'No Associated Executable Found' VIEW-AS ALERT-BOX.
ELSE
MESSAGE 'Some Other Error Found' VIEW-AS ALERT-BOX.