I developed a application which will run continuously. Each and every status of the application will be logged in a log file. I developed my application in such a way that it hides in the task bar when it is minimized. What i want to do is to write each and every status of the application in the dos console. So that the status can be viewed in the console. I am able to write the status in the dos console with the following APIs
Private Declare Function AllocConsole Lib "kernel32" () As Long
Private Declare Function FreeConsole Lib "kernel32" () As Long
Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
Private Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, ByVal lpBuffer As Any, ByVal nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
The problem here is when the user closes the console using the window close button it is throwing some memory error and terminates the actual application itself. Its not throwing any error if we use FreeConsole API to close the console. How to avoid this error. Can we avoid the user closing the console. How to avoid the memory error.