[edit] Late after GG - the is a more complex way not as neat and clean as GG's - but it may still be of interest.
Hello,
I know it can be done through a DLL. Check out the following code:
#include "dll.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
MessageBox(0,"Closing the current window\n","EXIT MESSAGE", MB_ICONINFORMATION);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
You see this block:
case DLL_PROCESS_DETACH:
MessageBox(0,"Closing the current window\n","EXIT MESSAGE", MB_ICONINFORMATION);
break;
When your app ends and the process is detached - basically the DLL is done and being let go from your program - it'll run whatever code you place here on this event.
In the case of your ini, you could have code written to it at this stage. You could even have another EXE called that does something.
I'll attach the compiled dll that displays a message box when you leave the program. The code below loads in the DLL and then on close, creates the message box.
sync on
sync rate 60
autocam off
set window on
rem load the on close event DLL
load dll "on_close.dll",1
rem spin a cube
make object cube 1,25
move camera -50
do
turn object right 1,1
text 0,0,"press space to exit"
if spacekey() then end
sync
loop
The idea would be for you to make your own dll that reacts to the detached process message. By using the LOAD DLL command, this activates the dll within your program. When your program closes, the dll is released thus causing the code to run.
For your ini, you could either have the dll call another exe that does the updating of your ini, or you code the updates yourself.
The other way, I think is to subclass your DB window. This may be a little more complex than running the DLL. However, you may need a DLL to actually subclass your window. Subclassing creates a means to intercept messages that normally go to the main window procedure of your window. This allows you to handle messages anyway you want - a message being some command or service related to the current window.
But there may be simpler methods within DB itself.
Enjoy your day.