(0) exportieren Drucken
Alle erweitern
EN
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.
4 von 5 fanden dies hilfreich - Dieses Thema bewerten.

RegSaveKeyEx function

Saves the specified key and all of its subkeys and values to a registry file, in the specified format.

Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy Service instead of the registry functions.

Syntax


LONG WINAPI RegSaveKeyEx(
  _In_      HKEY hKey,
  _In_      LPCTSTR lpFile,
  _In_opt_  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  _In_      DWORD Flags
);

Parameters

hKey [in]

A handle to an open registry key.

This function does not support the HKEY_CLASSES_ROOT predefined key.

lpFile [in]

The name of the file in which the specified key and subkeys are to be saved. If the file already exists, the function fails.

The new file has the archive attribute.

If the string does not include a path, the file is created in the current directory of the calling process for a local key, or in the %systemroot%\system32 directory for a remote key.

lpSecurityAttributes [in, optional]

A pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new file. If lpSecurityAttributes is NULL, the file gets a default security descriptor. The ACLs in a default security descriptor for a file are inherited from its parent directory.

Flags [in]

The format of the saved key or hive. This parameter can be one of the following values.

ValueMeaning
REG_STANDARD_FORMAT
1

The key or hive is saved in standard format. The standard format is the only format supported by Windows 2000.

REG_LATEST_FORMAT
2

The key or hive is saved in the latest format. The latest format is supported starting with Windows XP. After the key or hive is saved in this format, it cannot be loaded on an earlier system.

REG_NO_COMPRESSION
4

The hive is saved with no compression, for faster save operations. The hKey parameter must specify the root of a hive under HKEY_LOCAL_MACHINE or HKEY_USERS. For example, HKLM\SOFTWARE is the root of a hive.

 

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

If more than one of the possible values listed above for the Flags parameter is specified in one call to this function—for example, if two or more values are OR'ed— or if REG_NO_COMPRESSION is specified and hKey specifies a key that is not the root of a hive, this function returns ERROR_INVALID_PARAMETER.

Remarks

Unlike RegSaveKey, this function does not support the HKEY_CLASSES_ROOT predefined key.

If hKey represents a key on a remote computer, the path described by lpFile is relative to the remote computer.

The RegSaveKeyEx function saves only nonvolatile keys. It does not save volatile keys. A key is made volatile or nonvolatile at its creation; see RegCreateKeyEx.

You can use the file created by RegSaveKeyEx in subsequent calls to the RegLoadKey, RegReplaceKey, or RegRestoreKey function. If RegSaveKeyEx fails partway through its operation, the file will be corrupt and subsequent calls to RegLoadKey, RegReplaceKey, or RegRestoreKey for the file will fail.

Using RegSaveKeyEx together with RegRestoreKey to copy subtrees in the registry is not recommended. This method does not trigger notifications and can invalidate handles used by other applications. Instead, use the SHCopyKey function or the RegCopyTree function.

The calling process must have the SE_BACKUP_NAME privilege enabled. For more information, see Running with Special Privileges.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Winreg.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names

RegSaveKeyExW (Unicode) and RegSaveKeyExA (ANSI)

See also

RegCreateKeyEx
RegDeleteKey
Registry Files
Registry Functions
RegLoadKey
RegReplaceKey
RegRestoreKey
RegSaveKey
SECURITY_ATTRIBUTES

 

 

Fanden Sie dies hilfreich?
(1500 verbleibende Zeichen)
Vielen Dank für Ihr Feedback.

Community-Beiträge

HINZUFÜGEN
Anzeigen:
© 2014 Microsoft. Alle Rechte vorbehalten.