From 65310e01419d1ce79edc8dea14558c98344d5d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sat, 8 Jan 2022 21:43:04 +0100 Subject: [PATCH] Delay load `SetCurrentProcessExplicitAppUserModelID` Appears to be the only thing preventing 86Box from running on Vista. Note that this doesn't mean a change in the official system requirements. --- src/win/win.c | 3 --- src/win/win_ui.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/win/win.c b/src/win/win.c index 27386b5b7..a4854f65f 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -450,9 +450,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) { char **argv = NULL; int argc, i; - wchar_t * AppID = L"86Box.86Box\0"; - - SetCurrentProcessExplicitAppUserModelID(AppID); /* Initialize the COM library for the main thread. */ CoInitializeEx(NULL, COINIT_MULTITHREADED); diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 40f9068b0..912eef8cf 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -92,6 +92,13 @@ static dllimp_t user32_imports[] = { { NULL, NULL } }; +/* Taskbar application ID API, Windows 7+ */ +void* shell32_handle = NULL; +static HRESULT (WINAPI *pSetCurrentProcessExplicitAppUserModelID)(PCWSTR AppID); +static dllimp_t shell32_imports[]= { +{ "SetCurrentProcessExplicitAppUserModelID", &pSetCurrentProcessExplicitAppUserModelID } +}; + int win_get_dpi(HWND hwnd) { if (user32_handle != NULL) { @@ -1244,6 +1251,11 @@ ui_init(int nCmdShow) /* Load DPI related Windows 10 APIs */ user32_handle = dynld_module("user32.dll", user32_imports); + /* Set the application ID for the taskbar. */ + shell32_handle = dynld_module("shell32.dll", shell32_imports); + if (shell32_handle) + pSetCurrentProcessExplicitAppUserModelID(L"86Box.86Box"); + /* Set up TaskDialog configuration. */ tdconfig.cbSize = sizeof(tdconfig); tdconfig.dwFlags = TDF_ENABLE_HYPERLINKS;