VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsRegistry"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'Registry Class Module Copyright (C) 2004 LoRd[nK] (thevirushunter@hotmail.com)

Option Explicit

Private Declare Function RegDeleteKeyA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValueA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegCloseKeyA Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegEnumKeyExA Lib "advapi32" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long
Private Declare Function RegOpenKeyA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCreateKeyA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Declare Function RegSetValueExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long

'Private Const ERROR_SUCCESS = &H0
'Private Const ERROR_BADDB = &H1009
'Private Const ERROR_BADKEY = &H1010
'Private Const ERROR_CANTOPEN = &H1011
'Private Const ERROR_CANTREAD = &H1012
'Private Const ERROR_CANTWRITE = &H1013
'Private Const ERROR_OUTOFMEMORY = &H14
'Private Const ERROR_INVALID_PARAMETER = &H87
'Private Const ERROR_ACCESS_DENIED = &H5
'Private Const ERROR_NO_MORE_ITEMS = &H259
'Private Const ERROR_MORE_DATA = &H234

Enum hKeys
    HKEY_CLASSES_ROOT = &H80000000 'This key points to the HKEY_LOCAL_MACHINE\Software\Classes registry key, which describes certain software settings. This key displays essential information about OLE and association mappings to support drag-and-drop operations, Windows shortcuts (which are OLE links), and core aspects of the Windows user interface.
    HKEY_CURRENT_USER = &H80000001 'This key contains user-specific settings that are built from information in the HKEY_USERS key during the logon process.
    HKEY_LOCAL_MACHINE = &H80000002 'This key points to the HKEY_LOCAL_MACHINE\Software\Classes registry key, which describes certain software settings. This key displays essential information about OLE and association mappings to support drag-and-drop operations, Windows shortcuts (which are OLE links), and core aspects of the Windows user interface.
    HKEY_USERS = &H80000003 'This key contains information (generic and user-specific) about all the users who log on to the computer. The generic settings are available to all users who log on to the computer. The information is made up of default settings for programs, desktop configurations, and so on. This key contains subkeys for each user that logs on to the computer.
    HKEY_PERFORMANCE_DATA = &H80000004 'Microsoft Windows 2000, Windows NT, or Windows XP provides access to a variety of performance data that collectively represents the state of the computer. This performance data is stored in the registry key HKEY_PERFORMANCE_DATA. The default configuration of Windows NT gives everyone the ability to query this performance data, including remote users.
    HKEY_CURRENT_CONFIG = &H80000005 'This key handles Plug and Play and contains information about the current configuration of a multiple hardware configuration computer (for example, settings for a docking station). This key is a pointer to one of the configuration keys of the HKEY_LOCAL_MACHINE\Config key; the configuration key (000x for example, 0001) that contains information about the current configuration of hardware attached to the computer.
    HKEY_DYN_DATA = &H80000006 'Dynamic data (data stored in RAM on the computer) is contained in this key. This information may change as devices are added or removed from the computer. The information for each device includes the related hardware key and the device's current status, including problems. Device Manager uses this data to show the current hardware configuration, and this data is used to constantly update System Monitor.
End Enum

Enum lpTypes
    REG_SZ = &H1 'String Value
    REG_EXPAND_SZ = &H2 'Expandable String Value
    REG_BINARY = &H3 'Binary Value
    REG_DWORD_LITTLE_ENDIAN = &H4 'DWORD Value
    REG_DWORD_BIG_ENDIAN = &H5 'DWORD Value
    REG_MULTI_SZ = &H7 'Multi-String Value
End Enum

Private clsFunctions As New clsFunctions

Public Sub SetValue(hKey As hKeys, lpValueName As String, lpReserved As Long, lpType As lpTypes, lpData As String)
Call RegSetValueExA(hKey, lpValueName, lpReserved, lpType, lpData, Len(lpData))
End Sub
Public Function QueryValue(hKey As hKeys, lpValueName As String, lpReserved As Long, lpType As lpTypes) As String
QueryValue = Space(255)
Call RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, QueryValue, 255)
QueryValue = clsFunctions.TrimNull(QueryValue)
End Function
Public Sub DeleteKey(ByVal hKey As hKeys, lpValueName As String)
Call RegDeleteKeyA(hKey, lpValueName)
End Sub
Public Sub DeleteValue(ByVal hKey As hKeys, lpValueName As String)
Call RegDeleteValueA(hKey, lpValueName)
End Sub
Public Function CreateKey(ByVal hKey As hKeys, lpSubKey As String) As Long
Call RegCreateKeyA(hKey, lpSubKey, CreateKey)
End Function
Public Function OpenKey(ByVal hKey As hKeys, ByVal lpSubKey As String) As Long
Call RegOpenKeyA(hKey, lpSubKey, OpenKey)
End Function
Public Sub CloseKey(ByVal hKey As hKeys)
Call RegCloseKeyA(hKey)
End Sub
Public Function EnumKey(ByVal hKey As hKeys) As String()
Dim I As Long
Dim FT As FILETIME
Dim ValueName As String * 255
Dim Keys() As String
Do Until RegEnumKeyExA(hKey, I, ValueName, 255, 0, vbNull, vbNull, FT) <> 0
    Call RegEnumKeyExA(hKey, I, ValueName, 255, 0, vbNull, vbNull, FT)
    ReDim Preserve Keys(I)
    Keys(I) = ValueName
    I = I + 1
Loop
EnumKey = Keys
End Function
