다음을 통해 공유


WEKF_CustomKey.Remove

지원되는 버전
✅ IoT Enterprise LTSC
✅ IoT Enterprise✅
Enterprise LTSC
✅ Enterprise
✅ Education

사용자 지정 키 조합을 제거하여 키보드 필터가 제거된 키 조합 차단을 중지합니다.

구문

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

매개 변수

CustomKey
[in] 제거할 사용자 지정 키 조합입니다.

반환 값

WMI 상태 또는 WMI 오류를 나타내는 HRESULT 값을 반환합니다.

설명

WEKF_CustomKey.Remove 는 기존 WEKF_CustomKey 개체를 제거합니다. 개체가 없으면 WEKF_CustomKey.Remove 는 값이 0x8007007B 오류를 반환합니다.

이 메서드는 정적이므로 개체 instance 호출할 수 없지만 클래스 수준에서 호출해야 합니다.

예제

다음 코드에서는 키보드 필터에 WMI(Windows Management Instrumentation) 공급자를 사용하여 더 이상 차단되지 않도록 키보드 필터에서 사용자 지정 키를 제거하는 방법을 보여 줍니다.

$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);
    }
}