It's been a while since I worked with the Win32 API. But if memory serves me correctly, you have to do the following:
HDC hdc = GetDC(NULL);
DWORD color = GetPixel(hdc, x, y);
unsigned int r = GetRValue(color);
unsigned int g = GetGValue(color);
unsigned int b = GetBValue(color);
cout << "red: " << r << endl;
cout << "green: " << g << endl;
cout << "blue: " << b << endl;
The COLORREF is a typedef of DWORD, which is a typedef of unsigned long, but you'd use a COLORREF variable so others reviewing your code will know what it is.
The order of the bytes from left to right is reserved, blue, green, red. The high, reserved byte is usually set to 0, although when you use special Windows color palettes such as those found in 256 color mode, you may put something else into the reserved byte, such as a flag indicating that the remaining three bytes contain an index into a special Windows palette object.
The code below indicates that both values (16777215 and 4294967295) give the RGB values for a totally white pixel but the "incorrect" value of 4294967295 has the reserved byte set to 255.
COLORREF value = 4294967295;
int iA = (value >> 24) & 0xff;
int iR = (value >> 16) & 0xff;
int iG = (value >> 8) & 0xff;
int iB = (value) & 0xff;
std::cout << "4294967295 = "<< iA << " " << iR << " " << iB << " " << iG <<std::endl;
value = 16777215;
iA = (value >> 24) & 0xff;
iR = (value >> 16) & 0xff;
iG = (value >> 8) & 0xff;
iB = (value) & 0xff;
std::cout << "16777215 = "<< iA << " " << iR << " " << iB << " " << iG <<std::endl;