Tips  |  Documentation  |  Archive
The name of the directory from which the application was launched (full name of the executable module with the path)

    
    The directory name is defined like this:

	string  ls_AppPath
	string  ls_FullPath, ls_RevPath
	int     li_Pos, li_Pos2
	// getting full name
	ClassDefinition lcd
	n_dummy_obj u
	If IsNull(u) Then u = Create n_dummy_obj // если не autoinstantiated
	lcd = u.ClassDefinition
	ls_Fullpath = lcd.LibraryName
	
	// highlighting directory name
	ls_RevPath = Reverse(ls_FullPath)
	li_pos = Pos( ls_RevPath, "\")
	li_pos2 = Pos(ls_RevPath, "/")
	If li_pos2 > 0 and li_pos > li_pos2 Then
	    li_Pos = li_Pos2
	End If
	If li_pos > 0 Then
	     ls_AppPath = Left(ls_FullPath, Len(ls_FullPath) - li_pos)
	Else
	     ls_AppPath = "."
	End IF
	return ls_AppPath
	
	
	Instead of "n_dummy_obj", you can substitute any (almost) class that
	is in the executable module. So that when compiling the object
	fit into the EXE, you need to uncheck the "DLL / PBD" box in the project opposite
	libraries with this object.
	Although if all libraries are in the same directory, you don't need to worry about
	this.

	There is also another option (win32):
	You describe an external function:
	function long GetModuleFileNameA (long module, ref string path, long length)
	library "kernel32.dll"

	And then you call her:
	ls_Fullpath = Space (255)
	li_Ret = GetModuleFileNameA (Handle (GetApplication ()), ls_FullPath, 255)
	Here we have the full path to the EXE. Next, parsing the path as shown above.

	Although I like the first option better.