Selain menggunakan wshom.ocx, kita juga dapat membuatnya menggunakan fungsi-fungsi Windows API.
'Fungsi dan konstanta mengakses registry dengan mudah
Option ExplicitContoh mengakses registry dengan mudah
Public Const HKEY_LOCAL_MACHINE As String = "HKLM"
Public Const HKEY_CURRENT_USER As String = "HKCU"
Public Const HKEY_CLASSES_ROOT As String = "HKCR"
Public Const REG_BINARY As String = "REG_BINARY"
Public Const REG_DWORD As String = "REG_DWORD"
Dim wsh As New IWshRuntimeLibrary.WshShell
Public Function RegDelete(sName As String)
wsh.RegDelete sName
End Function
Public Function RegRead(sName As String)
wsh.RegRead sName
End Function
Public Function RegWrite(sName As String, Value, Optional stype)
wsh.RegWrite sName, Value, stype
End Function
Option Explicit
Private Sub Form_Load()
RegWrite HKEY_LOCAL_MACHINE & "\BYNARY", 1, REG_BINARY
RegWrite HKEY_LOCAL_MACHINE & "\DWORD", 1, REG_DWORD
RegWrite HKEY_LOCAL_MACHINE & "\STRING", 1
End Sub