WEKF_CustomKey.Remove

删除自定义组合键,导致键盘筛选器停止阻止已删除的组合键。

语法

[Static] uint32 Remove(
    [In] string CustomKey
);

参数

CustomKey
[in]要删除的自定义组合键。

返回值

返回指示 WMI 状态WMI 错误的 HRESULT 值。

注解

WEKF_CustomKey.Remove 可删除现有的 WEKF_CustomKey 对象。 如果对象不存在,WEKF_CustomKey.Remove 将返回值为 0x8007007B 的错误。

因为此方法是静态的,所以你不能在对象实例上调用它,而必须在类级别调用它。

示例

以下代码演示了如何从键盘筛选器中删除自定义键,以便不再通过使用键盘筛选器的 Windows Management Instrumentation (WMI) 提供程序来阻止它。

$COMPUTER = "localhost"
$NAMESPACE = "root\standardcimv2\embedded"

# Create a handle to the class instance so we can call the static methods
$classCustomKey = [wmiclass]"\\$COMPUTER\${NAMESPACE}:WEKF_CustomKey"

# Create a function to remove a key combination
function Remove-Custom-Key($KeyId) {

# Call the static Remove() method on the class reference
    $retval = $classCustomKey.Remove($KeyId)

# Check the return value for status
    if ($retval.ReturnValue -eq 0) {

# Custom key combination removed successfully
        "Removed ${KeyID}."
    } elseif ($retval.ReturnValue -eq 2147942523) {

# No object exists with the specified custom key
        "Failed to remove ${KeyID}. No object found."
    } else {

# Unknown error, report error code in hexadecimal
        "Failed to remove ${KeyID}. Unknown Error: " + "{0:x0}" -f $retval.ReturnValue
    }
}


# Example of removing a custom key so that Keyboard Filter stops blocking it
Remove-Custom-Key "Ctrl+Alt+w"

# Example of removing all custom keys that have the Enabled property set to false
$objDisabledCustomKeys = Get-WmiObject -Namespace $NAMESPACE -Class WEKF_CustomKey;

foreach ($objCustomKey in $objDisabledCustomKeys) {
    if (!$objCustomKey.Enabled) {
        Remove-Custom-Key($objCustomKey.Id);
    }
}

要求

Windows 版本 支持
Windows 主页
Windows 专业版
Windows 企业版
Windows 教育版
Windows IoT 企业版 是的