CreateRegistryKey

Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias _
    "RegCreateKeyExA" (ByVal hKey As Long, _
    ByVal lpSubKey As String, ByVal Reserved As Long, _
    ByVal lpClass As Long, ByVal dwOptions As Long, _
    ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, _
    phkResult As Long, lpdwDisposition As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" _
    (ByVal hKey As Long) As Long

Const KEY_READ = &H20019  
Const REG_OPENED_EXISTING_KEY = &H2

' Vracφ True pokud klφΦ existoval, False pokud byl vytvo°en

Function CreateRegistryKey(ByVal hKey As Long, _
    ByVal KeyName As String) As Boolean

    Dim handle As Long, disposition As Long
    
    If RegCreateKeyEx(hKey, KeyName, 0, 0, 0, 0, 0, handle, disposition) Then
        Err.Raise 1001, , "Nelze vytvo°it klφΦ v registru"
    Else
        CreateRegistryKey = (disposition = REG_OPENED_EXISTING_KEY)
        RegCloseKey handle
    End If
End Function

Zp∞t

Autor: The Bozena