我想在我的程序中加入动画,但在我将它们强加给每个人(尤其是硬件较差的人)之前,我还想检查一下它们是否需要。
具体来说,我想从“性能选项”窗口(下面的屏幕截图)检查设置。
我注意到一些程序正在使用它(这就是我什至知道它存在的原因)所以我认为必须有一个我可以使用的可访问 API。
所以我的问题只是如何检查该设置是打开还是关闭?
最终这将进入 C# WPF 应用程序。
最佳答案
这应该可以满足您的需求
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SystemParametersInfo(uint uiAction, uint uiParam, out bool pvParam, uint fWinIni);
private static uint SPI_GETCLIENTAREAANIMATION = 0x1042;
static void Main(string[] args)
{
try
{
bool animationsEnabled;
SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0x00, out animationsEnabled, 0x00);
if (animationsEnabled)
{
//Animate controls and elements inside windows is checked
}
else
{
//Animate controls and elements inside windows is not checked
}
}
catch (Win32Exception ex)
{
//error
}
}
关于c# - 我如何检查用户是否想要动画(通过系统设置)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25023498/