0

I am extremely new and I do not understand what to do. I am making a DLL in C++ for a game I am working on in another language. I know nothing about C++ and have been barely been working myself through it. I need it to return the windows personalization color. Someone on reddit gracefully gave me some source that worked but it only returned the ACTIVE_BORDER color which is not the same color that users can easily change in windows 8+ which is what I am focusing on. I have modified it to work with DwmGetColorizationColor but now the problem is that it doesn't use a COLORREF which is what I need. Anyone who can help me out would be greatly appreciated.

Heres my source:

#include <windows.h>
#include <dwmapi.h>
#include <gdiplus.h>
#define DLLEXPORT extern "C" __declspec(dllexport)
#pragma comment(lib, "Dwmapi")

DLLEXPORT double GetCol(void) {
    DWORD color = 0;
    BOOL opaque = FALSE;
    HRESULT hr = DwmGetColorizationColor(&color, &opaque);
    return color;
};
Jordan
  • 1
  • 2

1 Answers1

1

The returned color is in the format of

0xAArrggbb

Whereas a Windows COLORREF is

0x00bbggrr

You need to shift around the parts of your returned DWORD to to into a COLORREF.

COLORREF c = 
   ((color && 0x00ff0000) >> 16) //red
   ||
   ((color && 0x0000ff00)) //green
   ||
   ((color && 0x000000ff) << 16);
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219