Click to Rate and Give Feedback
MSDN
MSDN Library
System Services
Registry
Registry Reference
Registry Functions
 RegFlushKey Function
RegFlushKey Function

Writes all the attributes of the specified open registry key into the registry.

Syntax

C++
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 clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinreg.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll

See Also

RegCloseKey
RegDeleteKey
Registry Functions
Registry Overview

Send comments about this topic to Microsoft

Build date: 11/19/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker