1

私は、キーボード フックを含む c++ win32 プログラムに取り組んでいます。アプリケーションは、ユーザー インターフェイスがまったくない win32 プロジェクトです。フックが機能しなくなったり、大量のシステム リソースを使い果たしたりすることなく、アプリケーションが閉じないようにする必要があります。以前はメッセージ ボックスを使用していましたが、アプリケーションを完全に非表示にする必要があります。

どんな助けでも大歓迎です!

ご不明な点がございましたら、お気軽にお問い合わせください。

4

3 に答える 3

7

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.

于 2008-12-24T09:35:26.240 に答える
0

窓は本当に必要ですか?MSDNのLowLevelKeyboardProc ページでは、単純なメッセージ ループを使用することを推奨しています。フック呼び出しの後にこのスニペットを挿入するだけです。

// message loop to keep the keyboard hook running
MSG msg;
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}
于 2010-12-10T15:40:29.830 に答える
-3

より良い方法は、回り続けるループを追加することです。

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);
于 2008-12-24T06:43:24.920 に答える