Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
This function changes the color for the current session only. To persist the change, you must update the registry keys at HKEY_CURRENT_USER\Control Panel\Colors
Tips & Tricks:
Please add some!
Sample Code:
[DllImport("user32.dll", SetLastError=true)]
public static extern bool SetSysColors(int cElements, int [] lpaElements, int [] lpaRgbValues);
public const int COLOR_DESKTOP = 1;
//example color
System.Drawing.Color sampleColor = System.Drawing.Color.Lime;
//array of elements to change
int[] elements = {COLOR_DESKTOP};
//array of corresponding colors
int[] colors = {System.Drawing.ColorTranslator.ToWin32(sampleColor)};
//set the desktop color using p/invoke
SetSysColors(elements.Length, elements, colors);
//save value in registry so that it will persist
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Control Panel\\Colors", true);
key.SetValue(@"Background", string.Format("{0} {1} {2}", sampleColor.R, sampleColor.G, sampleColor.B));
Alternative Managed API:
Do you know one? Please contribute it!
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).