How to know if UWF is enabled or disabled

孤者浪人 提交于 2019-12-12 04:31:23

问题


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:

  1. 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.
  2. 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.

  1. UWF
  2. UWFMGR


来源:https://stackoverflow.com/questions/43134026/how-to-know-if-uwf-is-enabled-or-disabled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!