在 C/C++ 中启用高对比度模式

Enable High Contrast Mode in C/C++

我正在尝试在 Visual 中创建一个启用高对比度模式的 .exe 文件。我读

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-taghighcontrasta

上上下下但我找不到完整的答案。 uiParampvParam 中的内容是什么?请告诉我你在哪里找到答案的!

SystemParametersInfo(SPI_SETHIGHCONTRAST, , , SPIF_SENDCHANGE)

uiParam

Type: UINT

A parameter whose usage and format depends on the system parameter being queried or set. For more information about system-wide parameters, see the uiAction parameter. If not otherwise indicated, you must specify zero for this parameter.

为此您将使用 0。

pvParam

Type: PVOID

Sets the parameters of the HighContrast accessibility feature. The pvParam parameter must point to a HIGHCONTRAST structure that contains the new parameters.

此参数需要一个 HIGHCONTRAST 结构,其中包含您要传递的数据。

这意味着你会做:

HIGHCONTRAST hc;
ZeroMemory(&hc, sizeof(HIGHCONTRAST));
hc.cbSize = sizeof(HIGHCONTRAST);
hc.dwFlags = HCF_HIGHCONTRASTON;
SystemParametersInfo(SPI_SETHIGHCONTRAST, 0, &hc, SPIF_SENDCHANGE);

附带说明一下,您可能希望 return Windows 环境恢复到应用程序启动时的状态。

您应该在更改之前使用 SPI_GETHIGHCONTRAST 调用 SystemParametersInfo,存储该 HIGHCONTRAST 结构供以后使用,然后在您的应用程序退出时将系统恢复为该 HIGHCONTRAST 结构。