简体   繁体   中英

get keyboardfilter WMI parameters in c#

On Windows IoT (but also on the normal Windows 10), you can enable keyboard filter and shell launcher. I enabled UWF, KB-Filter and Shell Launcher.

Now, I can't get the parameters of my keyboardfilter with a simple C#.NET program.

ManagementScope scope = new ManagementScope(@"root\standardcimv2\embedded");
using (ManagementClass mc = new ManagementClass(scope.Path.Path, "WEKF_Settings", null))
{
    ManagementObjectCollection moc = mc.GetInstances();
    foreach (ManagementObject mo in moc)
    {
    }
}

The UWF_Filter is working. WEKF_Settings and WESL_UserSetting are not working, even if they are enabled on the OS.

I get always the exception Provider Load Failure , even if the application is started as administrator.

In powershell, I get the class without any problem:

Get-CimClass wekf_settings \\.\root\standardcimv2\embedded | select -expand cimclassqualifiers

So the question: why can't I get the instances (with GetInstances() ) in C# but only with powershell?

Just as info (if you get the same error):
The query fails also on Powershell, if this is 32-bit.

You need to compile the program as 64bit . Then the code will be able to query the keyboard filter.

This was the solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM