Kbase P125473: How to test if a DLL exists before running a procedure containing EXTERNAL definitions
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2007 |
|
Status: Unverified
GOAL:
How to test if a DLL exists before running a procedure containing EXTERNAL definitions
GOAL:
How to confirm the existence of a DLL when the installation location is known
GOAL:
How to avoid error 3258 when calling an external DLL
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
FIX:
Option #1
Use NO-ERROR when running the external procedure:
DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
PROCEDURE GetLastError EXTERNAL "KERNEL32.DLL":
DEFINE RETURN PARAMETER intResult AS LONG.
END PROCEDURE.
RUN GetLastError (OUTPUT intResult) NO-ERROR.
IF ERROR-STATUS:GET-NUMBER(1) = 3258 THEN DO:
/* Handle error */
END.
Option #2
Use the SEARCH function to check the path to the DLL before running the EXTERNAL procedure. The following example assumes that the location of the DLL is known; in this case, the DLL will always be located in the WINNT or WINDOWS folder:
DEF VAR chkDLL AS CHAR.
chkDLL = SEARCH(OS-GETENV("windir") + " \someDLL.dll").
IF chkDLL = ? THEN DO:
/* Handle error */
END.