Kbase 17115: How to Call WIN32 API Function: GetCurrentDirectory
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to Call WIN32 API Function: GetCurrentDirectory
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 GetCurrentDirectory. This function returns the current
directory for the Progress application.
This code has been tested on Windows NT 4.0 Workstation only.
DEFINE VARIABLE chrDirectoryName AS CHARACTER NO-UNDO FORMAT "X(256)".
DEFINE VARIABLE intBufferSize AS INTEGER NO-UNDO INITIAL 256.
DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
DEFINE VARIABLE ptrToString AS MEMPTR NO-UNDO.
PROCEDURE GetCurrentDirectoryA EXTERNAL "KERNEL32.DLL":
DEFINE INPUT PARAMETER intBufferSize AS LONG.
DEFINE INPUT-OUTPUT PARAMETER ptrToString AS MEMPTR.
DEFINE RETURN PARAMETER intResult AS SHORT.
END PROCEDURE.
SET-SIZE(ptrToString) = 256.
RUN GetCurrentDirectoryA (INPUT intBufferSize,
INPUT-OUTPUT ptrToString,
OUTPUT intResult).
ASSIGN chrDirectoryName = GET-STRING(ptrToString,1).
IF intResult = 0 THEN
MESSAGE "Function call failed, not sure why" VIEW-AS ALERT-BOX.
ELSE
IF intResult = LENGTH(chrDirectoryName) THEN
MESSAGE chrDirectoryName VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Buffer size is too small. Must be at least " +
STRING(intResult) VIEW-AS ALERT-BOX.
SET-SIZE(ptrToString) = 0.
Progress Software Technical Support Note # 17115