如何知道UWF是启用还是禁用? 我正在使用C#编写应用程序,所以我需要知道该语言。
谢谢
答案 0 :(得分:1)
在考虑启用或禁用UWF时,要记住几件事:
下面的C#代码演示了如何使用UWF_Filter类的 CurrentEnabled 属性:
public static bool IsEnabled()
{
try
{
//root\standardcimv2\embedded
ManagementScope scope = new ManagementScope(@"root\standardcimv2\embedded");
using (ManagementClass mc = new ManagementClass(scope.Path.Path, "UWF_Filter",
null))
{
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
// Please make use of NextEnabled property in case you have enabled the UWF_Filter in the current session.
//The value in CurrentEnabled is populated only when the UWF_Filter was enabled on system boot.
return (bool)mo.GetPropertyValue("CurrentEnabled");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
throw;
}
return false;
}
注意/请求:请求1500 reputation的人创建并链接以下标记,以便像我这样的人更容易在stackoverflow上请求解决方案/回答问题。