From 941ddee2fca8ca9c644a95a66444cf57029dc01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 6 Jun 2023 14:47:51 +0800 Subject: [PATCH] Icons (Windows): add support Instead of icon theme, this module on Windows detects enabled system icons --- CMakeLists.txt | 2 +- src/detection/icons/icons_windows.c | 33 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/detection/icons/icons_windows.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 12e2f47ca..e5c3d8f9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -515,7 +515,7 @@ elseif(WIN32) src/detection/font/font_windows.c src/detection/gpu/gpu_windows.c src/detection/host/host_windows.c - src/detection/icons/icons_nosupport.c + src/detection/icons/icons_windows.c src/detection/localip/localip_windows.c src/detection/gamepad/gamepad_windows.c src/detection/media/media_nosupport.c diff --git a/src/detection/icons/icons_windows.c b/src/detection/icons/icons_windows.c new file mode 100644 index 000000000..881589bc1 --- /dev/null +++ b/src/detection/icons/icons_windows.c @@ -0,0 +1,33 @@ +#include "icons.h" +#include "util/windows/registry.h" + +const char* ffDetectIcons(FF_MAYBE_UNUSED const FFinstance* instance, FFstrbuf* result) +{ + FF_HKEY_AUTO_DESTROY hKey = NULL; + if(!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu", &hKey, NULL)) + return "ffRegOpenKeyForRead(Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu) failed"; + + // Whether these icons are hidden + uint32_t ThisPC = 0, UsersFiles = 0, RemoteNetwork = 0, RecycleBin = 0, ControlPanel = 0; + ffRegReadUint(hKey, L"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", &ThisPC, NULL); + ffRegReadUint(hKey, L"{59031a47-3f72-44a7-89c5-5595fe6b30ee}", &UsersFiles, NULL); + ffRegReadUint(hKey, L"{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", &RemoteNetwork, NULL); + ffRegReadUint(hKey, L"{645FF040-5081-101B-9F08-00AA002F954E}", &RecycleBin, NULL); + ffRegReadUint(hKey, L"{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", &ControlPanel, NULL); + + if (!ThisPC) + ffStrbufAppendS(result, "This PC, "); + if (!UsersFiles) + ffStrbufAppendS(result, "User's Files, "); + if (!RemoteNetwork) + ffStrbufAppendS(result, "Remote Network, "); + if (!RecycleBin) + ffStrbufAppendS(result, "Recycle Bin, "); + if (!ControlPanel) + ffStrbufAppendS(result, "Control Panel"); + + ffStrbufTrimRight(result, ' '); + ffStrbufTrimRight(result, ','); + + return NULL; +}