views:

344

answers:

2

Hello, I am working on a c++ win32 program that involves a keyboard hook. The application is a win32 project with no user interface whatsoever. I need to keep the application from closing without using causing the hook to not work or use up a bunch of system resources. I used to use a message box but I need the application to be completely invisible.

Any help would be appreciated!

If you have any questions just ask.

A: 

A better way would be to add an loop that keeps going around.

bool shouldExit = false;

do
{
   //some code to handle events
   shouldExit = handleEvents();

   //sleep for a small bit so we dont take up 100% cpu
   sleep(500);
}
while (!shouldExit);
Lodle
+6  A: 

I think what you need is message only window

(MSDN says) A message-only window enables you to send and receive messages. It is not visible, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window simply dispatches messages.

Serge