windows detect system dark mode
To detect the system dark mode in Windows using Assembly language, you can use the Windows API function RegGetValueA
to retrieve the value of the AppsUseLightTheme
registry key. Here's an example code snippet that demonstrates how to do this:
section .data
regKey db "SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize",0
regValue db "AppsUseLightTheme",0
regType dd 4 ; REG_DWORD
regData dd 0
regDataSize dd 4
section .text
extern RegGetValueA : proc
global _start
_start:
; Open the registry key
push 0 ; hKey = HKEY_CURRENT_USER
push offset regKey
push 0 ; Reserved = NULL
push 0x20019 ; KEY_QUERY_VALUE | KEY_WOW64_64KEY
call RegOpenKeyExA
add esp, 16
; Read the registry value
push eax ; hKey
push offset regValue
push 0 ; Reserved = NULL
push offset regType
push offset regData
push offset regDataSize
call RegGetValueA
add esp, 24
; Check the value of the registry key
cmp dword [regData], 0
je light_theme
; Dark theme code here
jmp exit
light_theme:
; Light theme code here
exit:
; Close the registry key
push eax ; hKey
call RegCloseKey
add esp, 4
; Exit the program
push 0
call ExitProcess
Please note that this code snippet is just an example and may need to be modified to fit your specific requirements. It assumes that you are familiar with Assembly language programming and the Windows API.