在Windows IoT上(也在普通的Windows 10上(,您可以启用键盘过滤器和外壳启动器。我启用了UWF、KB Filter和Shell Launcher。
现在,我无法用一个简单的C#.NET程序获取键盘过滤器的参数。
ManagementScope scope = new ManagementScope(@"rootstandardcimv2embedded");
using (ManagementClass mc = new ManagementClass(scope.Path.Path, "WEKF_Settings", null))
{
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
}
}
UWF_Filter
正在工作。WEKF_Settings和WESL_UserSetting不起作用,即使它们在操作系统上已启用。
即使应用程序是以管理员身份启动的,我也总是会遇到异常提供程序加载失败。
在powershell中,我获得了没有任何问题的类:
Get-CimClass wekf_settings \.rootstandardcimv2embedded | select -expand cimclassqualifiers
那么问题来了:为什么我不能在C#中获得实例(使用GetInstances()
(,而只能使用powershell?
就像信息一样(如果您得到相同的错误(:
如果是32位的,查询在Powershell上也会失败。
您需要将程序编译为64位。然后代码将能够查询键盘过滤器。
这就是解决方案。