Windows 10 – C++ Change Background Color

email me

How to change the Background Color in Windows 10.

CPP Console App, compiled using VS2017, Community Edition.

 

If creating a policy package for SCCM: Compile to EXE, add the EXE you just created to SCCM as a package: Create Package > Environment > Program can run: Only when user is logged on > Run with user rights.


Code, Console App (shows console)

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")</stdio.h></windows.h>

void main()
{
int aElements[1] = { COLOR_BACKGROUND };
DWORD aNewColors[1];
aNewColors[0] = RGB(0x40, 0x40, 0x40);  // gray
SetSysColors(1, aElements, aNewColors);
}

 

Code, Desktop App (no console)

#include "stdafx.h"
#include "WindowsProject9.h"

// Global Variables:
HINSTANCE hInst;

// Forward declarations of functions included in this code module:
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR    lpCmdLine,
_In_ int       nCmdShow)
{

int aElements[1] = { COLOR_BACKGROUND };
DWORD aNewColors[1];
aNewColors[0] = RGB(0x00, 0x00, 0x00);  // black
SetSysColors(1, aElements, aNewColors);

}

 


Notes

SetSysColors function

Other functions

 

Commands

REG ADD “HKCU\Control Panel\Colors” /v Background /t REG_SZ /d “0 0 0” /f
REG ADD “HKCU\Control Panel\Desktop\Colors” /v Background /t REG_SZ /d “0 0 0” /f


VBScript

Set objShell = CreateObject(“WScript.Shell”)

objShell.Run “REG ADD “”HKCU\Control Panel\Colors”” /v Background /t REG_SZ /d “”0 0 0″” /f”,0,false

objShell.Run “REG ADD “”HKCU\Control Panel\Desktop\Colors”” /v Background /t REG_SZ /d “”0 0 0″” /f”,0,false