2 bool PlatformSpecificInitialize() {
4 LYRIS_PROFILE("PlatformSpecificInitialize");
7 retval = SetConsoleCtrlHandler(handler_routine, TRUE);
9 trace("Note: SetConsoleCtrlHandler() did not succeed.");
12 retval = SetConsoleTitle(APPLICATION_NAME.c_str());
14 trace("Note: setConsoleTitle() did not succeed.");
20 BOOL WINAPI handler_routine(DWORD signal) {
22 LYRIS_PROFILE("handler_routine");
24 static unsigned char handles_to_use = 3;
25 static bool handled_already = false;
26 if ((signal == CTRL_CLOSE_EVENT) || (signal == CTRL_SHUTDOWN_EVENT)) {
27 // if we receive a Windows signal to shutdown, we should exit
28 // immediately, and cleanly
29 if (handled_already == false) {
30 handled_already = true;
31 //lyris_Thread::ExitApplicationNow();
32 DisplayMessage("Shutting down as requested");
33 // create shutdown thread so that signal handler can return
35 lyris_Thread aShutDown(ShutDownNow, NULL, "Shut Down Thread");
43 else if (signal == CTRL_C_EVENT) {
44 // if we receive a Windows signal to shutdown, we should exit
45 // immediately, and cleanly
46 if (handles_to_use == 3) {
48 //lyris_Thread::ExitApplicationNow();
49 DisplayMessage("Shutting down as requested");
50 // create shutdown thread so that signal handler can return
52 lyris_Thread aShutDown(ShutDownNow, NULL, "Shut Down Thread");
56 else if (handles_to_use > 0) {
57 DisplayMessage("Currently shutting down: press Ctrl-C " +
58 ULong2String(handles_to_use) +
59 " more times to shut down immediately.");
67 else if (signal == CTRL_BREAK_EVENT) {
68 if (APPLICATION_NAME == "Lyris") {
69 if (ShouldDisplayDebugMessages() == 0) {
70 SetShouldDisplayDebugMessages(1);
73 SetShouldDisplayDebugMessages(0);
75 DisplayMessage("Debug mode is now: " +
76 Bool2String(ShouldDisplayDebugMessages()));
78 else if (APPLICATION_NAME == "MailShield") {
79 specific::setReloadConfig(lyris_yes);
87 lyr_notify("Unknown Windows signal passed to handler: " +
88 ULong2String(signal));