+ write_to_logfile(g_terminal_log_file.data(), type, message);
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// TERMINAL ICON
+///////////////////////////////////////////////////////////////////////////////
+
+void MUtils::Terminal::set_icon(const QIcon &icon)
+{
+ MUtils::Internal::CSLocker lock(g_terminal_lock);
+
+ if(g_terminal_attached && (!(icon.isNull() || MUtils::OS::running_on_wine())))
+ {
+ if(const HICON hIcon = (HICON) MUtils::Win32Utils::qicon_to_hicon(icon, 16, 16))
+ {
+ typedef BOOL(__stdcall *SetConsoleIconFun)(HICON);
+ bool success = false;
+ if (const SetConsoleIconFun pSetConsoleIconFun = MUtils::Win32Utils::resolve<SetConsoleIconFun>(QLatin1String("kernel32"), QLatin1String("SetConsoleIcon")))
+ {
+ const DWORD before = GetLastError();
+ qWarning("[Before: 0x%08X]", before);
+ if (pSetConsoleIconFun(hIcon))
+ {
+ success = true;
+ }
+ else
+ {
+ const DWORD error = GetLastError();
+ qWarning("SetConsoleIcon() has failed! [Error: 0x%08X]", error);
+ }
+ }
+ if (!success)
+ {
+ const HWND hwndConsole = GetConsoleWindow();
+ if ((hwndConsole != NULL) && (hwndConsole != INVALID_HANDLE_VALUE))
+ {
+ SendMessage(hwndConsole, WM_SETICON, ICON_SMALL, LPARAM(hIcon));
+ success = true;
+ }
+ }
+ if (success)
+ {
+ set_hicon(&g_terminal_icon, hIcon);
+ }
+ }