老妖网上的:
DWORD g_main_tid = 0;
HHOOK g_kb_hook = 0;
bool CALLBACK con_handler (DWORD)
{
PostThreadMessage (g_main_tid, WM_QUIT, 0, 0);
// 本文转自 C++Builder 研究 - http://www.ccrun.com/article.asp?i=984&d=es23f6
return TRUE;
};
int main (void)
{
g_main_tid = GetCurrentThreadId ();
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&con_handler, TRUE);
MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
};
return 0;
}
DWORD g_main_tid = 0;
HHOOK g_kb_hook = 0;
bool CALLBACK con_handler (DWORD)
{
PostThreadMessage (g_main_tid, WM_QUIT, 0, 0);
// 本文转自 C++Builder 研究 - http://www.ccrun.com/article.asp?i=984&d=es23f6
return TRUE;
};
int main (void)
{
g_main_tid = GetCurrentThreadId ();
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&con_handler, TRUE);
MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
};
return 0;
}