Advanced PowerBuilder

HomePrevious Lesson: Copying the Specified File
Next Lesson: Setting the Current Directory

Finding the Current Directory

Declare a local external function as shown below:
FUNCTION ulong ufx_GetCurrentDirectory(ulong BufferLen, &
         ref string currentdir) LIBRARY "Kernel32.dll" &
         ALIAS FOR "GetCurrentDirectoryA"

Make sure the buffer is enough in length to store the full path of the current directory, otherwise, it will not work.
// Object: cb_display_current_dir
// Event: Clicked
ulong lul_buf = 1000
string ls_curdir = space( lul_buf )
ufx_GetCurrentDirectory(lul_buf, ls_curdir)
MessageBox("Current Directory:", ls_curdir)
HomePrevious Lesson: Copying the Specified File
Next Lesson: Setting the Current Directory