RegCloseKey Function

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

RegCloseKey closes a registry key. This should be done after you finish reading to or writing to the registry. Closing the key frees up some resources. Obviously, you can no longer use the key after closing it. The function returns 0 if successful, or a non-zero error code if an error occurs.

hKey
The registry key to close.

Example:

' Read the Data value under the key:
' HKEY_CURRENT_USER\Software\Dummy\DummyApp\1.0\
subkey = "Software\Dummy\DummyApp\1.0"  ' key name
x = RegOpenKeyEx(HKEY_CURRENT_USER, subkey, 0, KEY_READ, hregkey)
If x <> 0 Then  ' error opening key -- abort!
  Debug.Print "Could not open registry key."
  Exit Sub
End If
'(put rest of code here)
x = RegCloseKey(hregkey)

Related Call: RegCreateKeyEx, RegOpenKeyEx
Category: Registry
Back to the index.


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/regclosekey.html