better registry function

This commit is contained in:
NishiOwO
2026-01-27 17:58:30 +09:00
parent 18457ccbcb
commit 0cecae2dd1

View File

@@ -11,12 +11,22 @@ typedef struct userdata {
static void detect_darktheme(MwLL handle){ static void detect_darktheme(MwLL handle){
DWORD dw; DWORD dw;
DWORD sz = sizeof(dw); DWORD sz = sizeof(dw);
int err, t;
HKEY hkey;
DWORD type;
if(RegGetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme", RRF_RT_REG_DWORD, NULL, &dw, &sz) == ERROR_SUCCESS){ err = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_QUERY_VALUE, &hkey);
int t = dw ? 0 : 1; if(err != ERROR_SUCCESS) return;
err = RegQueryValueEx(hkey, "AppsUseLightTheme", NULL, &type, (PBYTE)&dw, &sz);
if(err != ERROR_SUCCESS || type != REG_DWORD){
RegCloseKey(hkey);
return;
}
t = dw ? 0 : 1;
MwLLDispatch(handle, dark_theme, &t); MwLLDispatch(handle, dark_theme, &t);
}
} }
static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {