The following code sample shows how to invoke the Win32 API SetCurrentDirectoryW Function to change the current Working Directory of the 4GL/ABL session to: "C:\OpenEdge\WRK101B".
DEFINE VARIABLE iResult AS INTEGER NO-UNDO.
RUN SetCurrentDirectoryW (INPUT CODEPAGE-CONVERT("C:\OpenEdge\WRK101B", "UTF-16"), OUTPUT iResult).
IF iResult = 1 THEN MESSAGE "Current directory has been changed" VIEW-AS ALERT-BOX.
ELSE MESSAGE "Directory does not exist, or access is denied" VIEW-AS ALERT-BOX.
/* Define the entry point for the external DLL function */
PROCEDURE SetCurrentDirectoryW EXTERNAL "KERNEL32.DLL":
DEFINE INPUT PARAMETER chrCurDir AS CHARACTER.
DEFINE RETURN PARAMETER iResult AS LONG.
is used instead of SetCurrentDirectoryA
as it will handle extended characters in path names correctly. Note that it expects the pathname as a UTF-16 encoded string.