DVL Software Limited
[ About | Services | Products | Search | Feedback | Support ]

PowerBuilder Tips

What is the file name of the executable?

Back to the Tips


For various reasons, it can be useful to have the file name of the executable.   Here's how I do it.  The following code is available for download from this link or from our FTP server at ftp://dvl-software.com/pub/getmodulefilename.zip.

/*
Purpose:	Populate the fields with the values for the application path name.

Parameters:	nil

Results:	nil

Copyright 1998 - DVL Software Limited.

*/


string	ls_AppPath
string	ls_FullPath
string	ls_Exe
int	li_Ret
int	li_Pos = 0

ls_Fullpath = Space (255)
li_ret = GetModuleFileNameA (Handle (GetApplication ()), ls_FullPath, 255)

if li_Ret > 0 then 
	// ls_AppPath will be something line <drive><full path>\<exe name>
	// You can then strip off the exe name using:
	do while (Pos (ls_FullPath, "\", li_Pos + 1) > 0)
		li_Pos = Pos (ls_FullPath, "\", li_Pos + 1)
	loop
	
	ls_AppPath	= Mid (ls_FullPath, 1, li_Pos - 1)
	ls_Exe		= Mid (ls_FullPath, li_Pos + 1)

	sle_directory.text	= ls_apppath
	sle_path.text		= ls_fullpath
	sle_executable.text	= ls_exe
end if

Back to the Tips

[ About | Services | Products | Search | Feedback | Support ]

This page last updated: Tuesday, 29 February 2000
Copyright 1997, 1998, 1999, 2000 DVL Software Limited.  All rights reserved.