SfcIsKeyProtected function (sfc.h)

Determines whether the specified registry key is protected. Applications should avoid replacing protected registry keys.


BOOL SfcIsKeyProtected(
  [in]           HKEY    KeyHandle,
  [in, optional] LPCWSTR SubKeyName,
  [in]           REGSAM  KeySam


[in] KeyHandle

A handle to the root registry key. This must be a handle to one of the following predefined keys.





[in, optional] SubKeyName

A null-terminated string value containing the name of the subkey. This key must a subkey of the key identified by the hKey parameter. For more information about key names, see Structure of the Registry. If this parameter is NULL, the function only checks whether the root registry key is protected.

[in] KeySam

A constant that specifies the alternate registry view that should be used by applications that run on 64-bit Windows. This flag is ignored on the x86 platform. For more information, see Accessing an Alternate Registry View.

Value Meaning
Use the 32-bit registry key from 32-bit applications and use the 64-bit registry key from 64-bit applications.
Use the 64-bit registry key from either a 32-bit or 64-bit application.
Use the 32-bit registry key from either a 32-bit or 64-bit application.

Return value

If the key is protected, the return value is a nonzero value.

If the key is not protected, the return value is zero.


A key is protected by WRP if the path exists and is protected by WRP. The SfcIsKeyProtected function indicates that a subkey is protected by WRP if the subkey has a parent key that is protected by WRP.

For example, if the following registry key exists on the system and is protected by WRP:


The SfcIsKeyProtected function returns a nonzero value for the following subkey. The new subkey does not need to exist for the function to determine that it is WRP-protected.

               <new subkey>


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header sfc.h
Library Sfc.lib
DLL Sfc.dll

See also