Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

SfcIsKeyProtected function (sfc.h)

  • 2024-02-22
Feedback

In this article

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

Syntax

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

Parameters

[in] KeyHandle

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

HKEY_CLASSES_ROOT

HKEY_CURRENT_USER

HKEY_LOCAL_MACHINE

HKEY_USERS

[in, optional] SubKeyName

Anull-terminated string value containing the name of the subkey. This key must a subkey of the key identified by thehKey parameter. For more information about key names, seeStructure of the Registry.If this parameter isNULL, 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, seeAccessing an Alternate Registry View.

ValueMeaning
0x0000
Use the 32-bit registry key from 32-bit applications and use the 64-bit registry key from 64-bit applications.
KEY_WOW64_64KEY
0x0100
Use the 64-bit registry key from either a 32-bit or 64-bit application.
KEY_WOW64_32KEY
0x0200
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.

Remarks

A key is protected by WRP if the path exists and is protected by WRP. TheSfcIsKeyProtected 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:

HKEY_LOCAL_MACHINE   SOFTWARE      Classes         Microsoft            <WinFeature>

TheSfcIsKeyProtected 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.

HKEY_LOCAL_MACHINE   SOFTWARE      Classes         Microsoft            <WinFeature>               <new subkey>

Requirements

RequirementValue
Minimum supported clientWindows Vista [desktop apps only]
Minimum supported serverWindows Server 2008 [desktop apps only]
Target PlatformWindows
Headersfc.h
LibrarySfc.lib
DLLSfc.dll

See also

SfcIsFileProtected


Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo