1

I would like to know if Windows Transparency Effects are enabled or not in my C# program but couldn't find any API to retrieve that information. Does anyone know how to do it?

I guess there's a simple API doing that.

Thanks!

Stefan

Shabba
  • 31
  • 3
  • I would rather see Windows actually enforcing the color settings on apps. There are more and more apps that care a sh... about the color settings and do what they like. – PMF Aug 17 '23 at 11:39
  • You can test the `System.Drawing.SystemColors`, but this doesn't tell anything about transparency effects. I am not sure if this is what you are looking for: [How make sure Aero effect is enabled?](https://stackoverflow.com/questions/5114389/how-make-sure-aero-effect-is-enabled). – Olivier Jacot-Descombes Aug 17 '23 at 11:52

1 Answers1

0

I don't know weather there is a API provided by Microsoft in the Windows API to directly check whether transparency effects are enabled or disabled. You could try the below approach to get the result:

class Program
{
    const int SPI_GETTRANSPARENCY = 0x104D;

    [DllImport("user32.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool SystemParametersInfo(int uiAction, int uiParam, out bool pvParam, int fWinIni);

    static void Main()
    {
        bool transparencyEnabled;
        bool success = SystemParametersInfo(SPI_GETTRANSPARENCY, 0, out transparencyEnabled, 0);

        if (success)
        {
            if (transparencyEnabled)
                Console.WriteLine("Transparency effects are enabled.");
            else
                Console.WriteLine("Transparency effects are disabled.");
        }
        else
        {
            Console.WriteLine("Failed to retrieve transparency effects information.");
        }
    }
}
Amit Mohanty
  • 387
  • 1
  • 9