Save shapeless app from closing for keyboard
I am working on a C ++ win32 program that includes a keyboard hook. The app is a win32 project without any user interface. I need to prevent the application from closing without using forcing the hook to fail or using a bunch of system resources. I used a message box, but I need the application to be completely invisible.
Any help would be appreciated!
If you have any questions, just ask.
source to share
I think you only need a message box
( MSDN says ). The message-only window allows you to send and receive messages. It is not displayed, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window just sends messages.
source to share
Do you really need windows? MSDN page LowLevelKeyboardProc recommends using a simple message loop. Just paste this snippet after calling the call.
// message loop to keep the keyboard hook running
MSG msg;
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
source to share