Article

How to change the current working directory of a 4GL session on Windows?

« Go Back

Information

 
EnvironmentWindows
Progress 8.x
Progress 9.x
OpenEdge 10.x
Question/Problem Description
How to change the current working directory of a 4GL session on Windows?
How to set the current working directory using 4GL at run time?
How to modify the current working directory of the Progress/OpenEdge 4GL/ABL session?
How to Call WIN32 API Function: SetCurrentDirectory
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution

The following code sample shows how to invoke the Win32 API SetCurrentDirectoryA Function to change the current Working Directory of the 4GL/ABL session to: "C:\OpenEdge\WRK101B":

DEFINE VARIABLE iResult AS INTEGER NO-UNDO.

RUN SetCurrentDirectoryA (INPUT "C:\OpenEdge\WRK101B", 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 SetCurrentDirectoryA EXTERNAL "KERNEL32.DLL":
   DEFINE INPUT  PARAMETER chrCurDir AS CHARACTER.
   DEFINE RETURN PARAMETER iResult AS LONG.
END PROCEDURE.

Workaround
Notes
Normally the working directory of the ABL client is fixed when the session starts, either by setting the "Start in:" directory in the Windows shortcut, or by changing to the directory in a startup script.
Changing the working directory of a running process is considered bad practice as it is very likely to interfere with any file I/O that uses relative pathnames; the code above can be used as a workaround if some other component in the environment changes the working directory unexpectedly.


References to Written Documentation:

OpenEdge Development: Programming Interfaces


Progress Solutions:

P9229, "How to locate the current working directory of a 4GL session?" 
Attachment 
Feedback
 
Was this article helpful?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful.



Characters Remaining: 255

 



Copyright © 1993-2014. Progress Software Corporation. All Rights Reserved. See the next generation of application development and data connectivity software, try now!