pythonwindowswinapicolorsregistry

Applying changes in HKCU\Control Panel\Colors immediately


I've been developing a color customization program recently and found how desk.cpl used to apply the HKCU\Control Panel\Colors changes immediately. How can I do this myself (in any langauge)? I don't want to use Windows API SetSysColors function because I'm primary coding this program in Python. Any way I can do this?

Remarks

I have tried


Solution

  • SetSysColors is the only way, it calls into the kernel.

    According to this mailing list post, the ctypes code looks like this:

    from ctypes.wintypes import windll, c_int, byref, RGB
    COLOR_BACKGROUND = 1 # from winuser.h or win32con
    SetSysColors = windll.user32.SetSysColors
    which_color = RGB(255,0,0) # red
    SetSysColors(1, byref(c_int(COLOR_BACKGROUND)), byref(c_int(which_color)))