Implementing WinAPI function SetSysColors in C#

I want to write some code that changes the desktop color, and the piece I'm stuck on is how to implement the API function in C#

Here is what msdn says:
BOOL SetSysColors(
  int cElements,
  const INT* lpaElements,
  const COLORREF* lpaRgbValues

I'm particularly confused by COLORREF, which is a "macro" in C++ and I'm not sure how you implement that in C#.  Also, lpaElements documentation refers to some constants, but I'm not sure how you make sure those work in C# without redefining them, and I don't know their integer values.  

The code should look something like this (once the API function is implemented)

// Window elements to change.
int aiElements[1] = {COLOR_DESKTOP};

// Array of RGB values.
COLORREF aColors[1] = RGB(0x80, 0x00, 0x80);  // dark purple

// Set the window elements in aiElements to the colors
// specified in aColors.
SetSysColors(1, aiElements, aColors);

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Here an example, I hope this help you:

using System.Runtime.InteropServices;


const int COLOR_DESKTOP = 1;

uint RGB(byte byRed, byte byGreen, byte byBlue) {
  uint res = byBlue;
  res = res<<8;
  res = res<<8;
  return res;


public static extern bool SetSysColors(int cElements, int[] lpaElements, uint[] lpaRgbValues);


int[] aiElements = {COLOR_DESKTOP};
uint[] aColors = {RGB(0x00, 0x80, 0x00)};
SetSysColors(1, aiElements, aColors);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.