Kbase 17138: How to Call WIN32 API Function: GetEnvironmentVariable
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to Call WIN32 API Function: GetEnvironmentVariable
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 GetEnvironmentVariable. This function returns the value
associated with an environment variable.
This code has been tested on Windows NT 4.0 Workstation only.
DEFINE VARIABLE chrValue AS CHARACTER NO-UNDO FORMAT "X(512)".
DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
PROCEDURE GetEnvironmentVariableA EXTERNAL "KERNEL32.DLL":
DEFINE INPUT PARAMETER chrName AS CHARACTER.
DEFINE OUTPUT PARAMETER chrValue AS CHARACTER.
DEFINE INPUT PARAMETER intSize AS LONG.
DEFINE RETURN PARAMETER intResult AS LONG.
END PROCEDURE.
ASSIGN chrValue = FILL(" ",512).
RUN GetEnvironmentVariableA (INPUT "PATH",
OUTPUT chrValue,
INPUT 512,
OUTPUT intResult).
IF intResult < 512 THEN
MESSAGE chrValue VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Buffer size is too small. Must be at least " +
STRING(intResult) VIEW-AS ALERT-BOX.
Progress Software Technical Support Note # 17138