Currently, I'm spawning a message box with a OS-library function (Windows.h), which magically keeps my program alive and responding to calls to the callback function.
What alternative approach could be used to silently let the program run forever?
Trapping 'Ctrl-c' or SIGINT and subsequently calling RemoveHook() for a clean exit would be nice to have but is not essential.
HOOK my_hook;
CALLBACK my_callback_fn()
{
...
}
int main()
{
my_hook = SetHook(my_callback_fn);
MessageBox("Press OK to stop."); // This is bad.
RemoveHook(my_hook);
return 0;
}