I want to make sure when I close my program all memory and open files are closed and released.
Is there a easy way to close and release all.
I am sure there is a post but I am having a problem locating it.
Thanks in advance.
properly close program
Moderator: Rathinagiri
properly close program
All The Best,
Franco
Canada
Franco
Canada
Re: properly close program
Normally when you close an application Windows should release the resources used by the application and close all files opened by the application. However, if you want to close all opened dbf files, release unused memory (you won't release all used memory because the application needs it), release all optional dll libraries and terminate the process and threads you can use the code:
Code: Select all
dbcloseall()
RELEASE MEMORY
UnloadAllDll()
ExitProcess(0)
Re: properly close program
Thanks edk.
This is what I use but wanted to make sure this exits properly.
This is what I use but wanted to make sure this exits properly.
Code: Select all
#include "hmg.ch"
#define CRLF HB_OsNewLine()
#include "FILEIO.CH"
function Main()
local temp
public prating := 8, AND MORE
REQUEST DBFNTX
SET CENTURY ON
SET DELETED OFF
SET DATE TO BRITISH
USE CONTROLS NEW SHARED
GO 1
MSERIAL := ALLTRIM(SERIAL)
USE
HB_LANGSELECT( "EN" )
// Define the main window.
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH getdesktopWidth()-25 ;
HEIGHT getDeskTopHeight()-45 ;
TITLE " Title" ;
MAIN ;
NOMAXIMIZE ;
NOSIZE ;
ON INIT {||{ ABOUT()}
BACKCOLOR GRAY ;
FONT 'Arial' SIZE 9
ON KEY CONTROL + G action MSGBOX('Series: '+mcod)
ON KEY CONTROL + W action ABOUT()
DEFINE MAIN MENU OF Win_1
POPUP " E&xit"
ITEM "&Exit Q&A" ;
ACTION Win_1.Release
END POPUP
POPUP " MORE POPUPS"
ITEM " MORE POPUPS" ;
ACTION MORE FUNCTIONS
END POPUP
END MENU
ON KEY F1 OF WIN_1 ACTION HELPING('q&a.HLP')
ON KEY F10 OF WIN_1 ACTION MSGBOX('DATE: 02/20/20')
END WINDOW
ACTIVATE WINDOW Win_1
set helpfile to helping('q&a.hlp')
return NIL
All The Best,
Franco
Canada
Franco
Canada
Re: properly close program
What would be the proper way do the,
Action dbcloseall() , RELEASE MEMORY, win_1.release, UnloadAllDll() ,ExitProcess(0)
or a function
Action Getout(), win_1 release
Function Getout)()
dbcloseall()
RELEASE MEMORY
UnloadAllDll()
ExitProcess(0)
return
Action dbcloseall() , RELEASE MEMORY, win_1.release, UnloadAllDll() ,ExitProcess(0)
or a function
Action Getout(), win_1 release
Function Getout)()
dbcloseall()
RELEASE MEMORY
UnloadAllDll()
ExitProcess(0)
return
All The Best,
Franco
Canada
Franco
Canada
Re: properly close program
Releasing the main form is sufficient, it will release all forms and consequently execute the indicated commands.
These commands/functions are worth using in ErrorBlock() when we intend to terminate the application due to errors.
These commands/functions are worth using in ErrorBlock() when we intend to terminate the application due to errors.