Advanced PowerBuilder

HomePrevious Lesson: Finding the System Directory
Next Lesson: Copying the Active Window to the Clipboard

Finding Where the EXE is Running From

Declare a local external function as shown below.
Function uLong ufx_GetModuleFileName( &
         Int hinstModule, Ref String lpszPath, &
         uLong cchPath) Library "kernel32.dll" &
         ALIAS FOR "GetModuleFileNameA"

The following code displays the location of the EXE.
// Object: cb_where_I_am_running_from
// Event: Clicked
String ls_AppPath = Space(255)
int li_Null
SetNull(li_Null)
ufx_GetModuleFileName( li_Null, ls_AppPath, 256)
MessageBox( "Application Path", ls_AppPath )
HomePrevious Lesson: Finding the System Directory
Next Lesson: Copying the Active Window to the Clipboard