问题
How do I know if the UWF is enabled or disabled? I'm making an application with C # so I need to know for that language.
Thank you
回答1:
There are few things to keep in mind when considering whether UWF is enabled or disabled:
- Protection is not enabled when UWF is enabled, you need to exlicitly turn it ON by making use of Protect method in UWF_Volume class.
- A system reboot is required after enabling or disabling of UWF in order to apply the changes. UWF_Filter class provides methods for enable/disable and for performing reboot/shutdown of the system.
The C# code below demonstrates the use of CurrentEnabled property of UWF_Filter class:
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;
}
Note/Request: Request someone with 1500 reputation to create and link following tags so that it becomes easier for people like me to request solutions/answer questions on stackoverflow.
- UWF
- UWFMGR
来源:https://stackoverflow.com/questions/43134026/how-to-know-if-uwf-is-enabled-or-disabled