c# - 我如何检查用户是否想要动画(通过系统设置)?

标签 c# .net wpf windows winapi

我想在我的程序中加入动画,但在我将它们强加给每个人(尤其是硬件较差的人)之前,我还想检查一下它们是否需要。

具体来说,我想从“性能选项”窗口(下面的屏幕截图)检查设置。

Animate controls and elements inside windows setting

我注意到一些程序正在使用它(这就是我什至知道它存在的原因)所以我认为必须有一个我可以使用的可访问 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/

相关文章:

c# - 通过在 m :n relationship? 中使用 ForeignKey 避免插入重复项

c# - 重复事件——使用 DateTime?

c# - 使用 "static extern int system(string str)"时 PInvokeStackImbalance

.net - 类的默认访问修饰符是什么?

c# - 如何使用 XPathNavigator 并返回不同的节点?

wpf - 禁用父控件时启用子控件

c# - .net 我可以将键入的行添加到新的(空)数据表中吗?

c# - 如何显示对象内对象字段的值?

c# - WPF treeView节点如何添加点击事件获取节点值

WPF:如何设置 TabItem 的背景?