Writes all the attributes of the specified open registry key into the registry.
Syntax
LONG WINAPI RegFlushKey(
__in HKEY hKey
);
Parameters
- hKey [in]
-
A handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right. For more information, see
Registry Key Security and Access Rights.
This handle is returned by the
RegCreateKeyEx, RegCreateKeyTransacted, RegOpenKeyEx, or
RegOpenKeyTransacted function. It can also be one of the following
predefined keys:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_CONFIG
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_PERFORMANCE_DATA
- HKEY_USERS
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.
Remarks
The
RegFlushKey function returns only when all the data for the hive that contains the specified key has been written to the registry store on disk. The
RegFlushKey function writes out the data for other keys in the hive that have been modified since the last lazy flush or system start. After RegFlushKey returns, use RegCloseKey to close the handle to the registry key.
Calling RegFlushKey is an expensive operation that significantly affects performance because it blocks modifications to keys in the registry hive that is being flushed until the flush operation completes. In addition, it is not necessary to call
RegFlushKey to make key changes visible to other processes because registry changes are flushed to disk by the registry using its lazy flusher. For these reasons, RegFlushKey should be used rarely, if ever.
Lazy flushing occurs automatically and regularly after a system-specified interval of time. Registry changes are also flushed to disk at system shutdown. Allowing the lazy flusher to write registry changes is the most efficient way to manage registry writes to the registry store on disk.
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | Winreg.h (include Windows.h) |
| Library | Advapi32.lib |
| DLL | Advapi32.dll |
See Also
- RegCloseKey
- RegDeleteKey
- Registry Functions
- Registry Overview
Send comments about this topic to Microsoft
Build date: 11/19/2009