>On Shutdown do cleanup() > >*------------------------------------------- >*-- >*-- Runtime Mode Application Startup Program >*-- >*-- Entry point for front-end application >*-- >*------------------------------------------- > >*-- Include >#INCLUDE foxpro.h && !!!@@@ > > >*-- Clear all at first >CLEAR >CLEAR DLLS >RELEASE ALL EXTENDED >CLEAR ALL > >PUBLIC DEBUGMODE && TRUE when running within VFP, FALSE for standalone program >PUBLIC gcHomePath && Working directory >*Public True >Public want_to_exit > >*-- DECLARE DLL statements for the temporary directory >DECLARE INTEGER GetTempPath IN Win32API ; > INTEGER nBufSize, STRING @lpszTemPath >PUBLIC gcTemPath && Temporary directory > >*-- DECLARE DLL statements for the copying an existing file to a new file >DECLARE INTEGER CopyFile IN Win32API ; > STRING @lpExistingFileName, ; > STRING @lpNewFileName, INTEGER bFailIfExists > >*-- DECLARE DLL statement for beeping >DECLARE INTEGER MessageBeep IN Win32API AS MsgBeep Integer sound > >*-- Set up the path so we can instantiate the application object >IF SetPath() > *-- Init startup and message loop > *DO FORM MAIN > > *Do Form Golform > Do Form loginform > *READ EVENTS > Release All > Clear All > Close All >ENDIF > >*-- If inside VFP run Project Manager again >*!* IF DEBUGMODE >*!* ACTIVATE WINDOW "Project Manager" >*!* ENDIF > >*-- Clear all at exit >CLEAR DLLS >RELEASE ALL EXTENDED >CLEAR ALL > >*-- End of program >*-------------------------------------------- > >*-------------------------------------------- >*-- Set path to application working directory >*-------------------------------------------- >FUNCTION SetPath() >*----------------- > > LOCAL lcPath, lcBuffer > LOCAL lnStart > > lcPath = SYS(16) && Where we were executed... > lnStart = AT("\\", lcPath) > > IF lnStart = 0 > lnStart = AT(":", lcPath) - 1 > ENDIF > > IF lnStart > 0 > lcPath = SUBSTR(lcPath, lnStart) && Derive program name > ENDIF > > gcHomePath = LEFT(lcPath, RAT("\", lcPath)) && ... and path to it > *gcHomePath = "d:\coolpos" > > *-- Change current directory to working... > CD (gcHomePath) > > *-- If we are running MAIN.PRG directly, then > *-- CD up to the parent directory > IF RIGHT(lcPath, 3) = "FXP" > *-- One level up > CD .. > > *-- Assume we were run from VFP > DEBUGMODE = .T. &&TRUE > > *-- Make out path to INI file > gcHomePath = LEFT(gcHomePath, RAT("\", gcHomePath, 2)) > > *-- Ensure the project manager is closed > DEACTIVATE WINDOW "Project Manager" > ENDIF > > *-- Set all pathes > SET DEFAULT TO (gcHomePath) > SET PATH TO Classes, ; > Forms, ; > Includes, ; > Menus, ; > Pictures, ; > Graphics,; > Graphics\Bitmaps,; > Graphics\Pictures,; > Graphics\Pictures\Logo,; > Graphics\Pictures\Icons,; > Graphics\Pictures\World\Flags,; > Graphics\Pictures\World\Maps,; > Graphics\FormImage\formbase,; > Graphics\FormImage\formbutton\black,; > Graphics\FormImage\formbutton\blue,; > Graphics\FormImage\formbutton\Green,; > Graphics\FormImage\formbutton\General,; > Graphics\FormImage\formbutton\Red,; > Graphics\FormImage\formbutton\Yellow,; > Graphics\FormImage\formhead,; > Graphics\FormImage\formtheme,; > Progs, ; > Procs, ; > Data, ; > Scripts > SET PROCEDURE TO Measure > SET CLASSLIB TO && !!!@@@ > > *-- Temporary path > lcBuffer = REPL(' ', 511) + CHR(0) > lnStart = GetTempPath(512, @lcBuffer) > > If lnStart > 0 > gcTemPath = LEFT(lcBuffer, lnStart) > Else > gcTemPath = gcHomePath > Endif > > IF RIGHT(gcTemPath, 1) <> '\' > gcTemPath = gcTemPath + '\' > Endif > > Return .T. &&TRUE > >Endfunc > >Function cleanup > *If want_to_exit > Clear Events > Clear All > Release All > On Error > On Shutdown > If _vfp.StartMode = 0 > Return To Master > Else > Quit > Endif > *Endif >