I been using a call to the Windows Kernel32.dll function: GetModuleFileNameA. I make
the API call from the open event of n_cst_appmanager. I use three functions to set
and get the values; of_SetAppFileInfo() (see below), of_GetAppFileName() and
of_GetAppFileDir() (not included).
In the example below, I refer to (and change) the instance variables in my
application's pfc_open event.
If I had it to do over again, I'd either make of_SetAppFileInfo() a little more object
oriented by passing the instance variables to the function, or I'd call
GetModuleFileNameA directly from the ancestor's pfc_Open event and get rid of some
extra code.
//////////////////////////////////////////////////////////////////////////////////////////
//
// Example function call to find application executable file name.
//
// Object: n_cst_myapp
// Event: pfc_open
//
//////////////////////////////////////////////////////////////////////////////////////////
if lower(left(this.of_GetAppFileName(),2)) = "pb" then // running pb engine.
ib_devmode = TRUE
// Kludge to provide useful information during development.
// In development the "exe" is pbxxxx.exe, not the application being tested.
is_AppFileName = "bgc.pbd"
is_AppFileDir = "c:\egads\bgcomp\"
else
ib_devmode = FALSE
end if
//////////////////////////////////////////////////////////////////////////////
//
// Object: n_cst_appmanager
// Function: of_SetAppFileInfo
//
// Access: public
//
// Arguments: none
//
// Returns: Integer
// 1 = success
// -1 = error
//
// Description: Sets the values for the application path (is_AppFileDir)
// and exe file name (is_AppFileName) using call
// to WinAPI GetModuleFileNameA.
//
// Protected:
// string is_appfiledir // Location of application's exe file
// string is_appfilename // Application's exe file name
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 3/11/98 Initial version - Marvin Young
//
//////////////////////////////////////////////////////////////////////////////
integer li_len
n_cst_string lnv_string
is_AppFileName = space(50)
if GetModuleFileNameA(handle(iapp_object),is_AppFileName,len(is_AppFileName)) > 0 then
li_len = lnv_string.of_lastpos(is_AppFileName,"\")
is_AppFileDir = trim(left(is_AppFileName,li_len))
is_AppFileName = trim(mid(is_AppFileName,li_len + 1, 999))
Return 1
else
Return -1
end if
>>> "Jill M. Claus" <[EMAIL PROTECTED]> 3:18:02 PM 11/23/1999 >>>
Is there a function somewhere in the PFC that will return the path to where the
executable is currently sitting? I am trying to find a way to indicate where the ini
file is without having to recompile the executable every time the application files
are moved. (i.e. the exe, dll's, pbd's, etc.) Any help would be greatly appreciated.
Thanks,
Jill
> [EMAIL PROTECTED] HOSTED BY IIGG, INC. FOR HELP WITH LIST SERVE COMMANDS, ADDRESS
> A MESSAGE TO [EMAIL PROTECTED] WITH THE FOLLOWING MESSAGE: help pfcsig
> SEND ALL OTHER INQUIRES TO [EMAIL PROTECTED]
!
!
!
!
!
!
!
!
!
!
> [EMAIL PROTECTED] HOSTED BY IIGG, INC. FOR HELP WITH LIST SERVE COMMANDS, ADDRESS
> A MESSAGE TO [EMAIL PROTECTED] WITH THE FOLLOWING MESSAGE: help pfcsig
> SEND ALL OTHER INQUIRES TO [EMAIL PROTECTED]
- PFCSIG executable path function? Jill M. Claus
- RE: PFCSIG executable path function? Marvin Young
- RE: PFCSIG executable path function? Jill M. Claus
- Re: PFCSIG executable path function? Daniel Coppersmith
- RE: PFCSIG executable path function? Hensel, Russ
