قبلا یه ماژول برای کار با رجیستری گذاشته بودم. اینم همون کار رو میکنه ولی از طریق اسکریپت و دستوراتش هم ساده تره.
متن زیر رو داخل یه ماژول کپی کنید و ازش استفاده کنید و یا اینکه ماژول آماده رو دانلود کنید.
Public Enum RootKeyNames
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_CLASSES_ROOT
HKEY_USERS
HKEY_CURRENT_CONFIG End Enum Public Enum RegType
REG_SZ
REG_EXPAND_SZ
REG_DWORD
REG_BINARY End Enum Private Function GetRootKey(Rootkey As RootKeyNames) As String Select Case Rootkey
Case HKEY_CLASSES_ROOT
GetRootKey = "HKCR"
Case HKEY_CURRENT_CONFIG
GetRootKey = "HKEY_CURRENT_CONFIG"
Case HKEY_CURRENT_USER
GetRootKey = "HKCU"
Case HKEY_LOCAL_MACHINE
GetRootKey = "HKLM"
Case HKEY_USERS
GetRootKey = "HKEY_USERS"
End Select
End Function Private Function TypeOfKey(MyType As RegType) As String Select Case MyType
Case REG_BINARY
TypeOfKey = "REG_BINARY"
Case REG_DWORD
TypeOfKey = "REG_DWORD"
Case REG_EXPAND_SZ
TypeOfKey = "REG_EXPAND_SZ"
Case REG_SZ
TypeOfKey = "REG_SZ"
End Select
End Function Public Function RegWrite(Root As RootKeyNames, KeyName As String, _
Value As Variant, WriteType As RegType) As Boolean On Error GoTo Trap
Dim RegObj
Set RegObj = Create("W.Shell")
RegObj.RegWrite GetRootKey(Root) & "\" & KeyName, Value, TypeOfKey(WriteType)
Set RegObj = Nothing
RegWrite = True Exit Function Trap:
Set RegObj = Nothing
RegWrite = False
End Function Public Function RegRead(Root As RootKeyNames, KeyName As String) As Variant " if you want to read a default value of a key _ then you should include a final back slash after the key name On Error Resume Next Dim RegObj
Set RegObj = Create("W.Shell")
RegRead = CVar(RegObj.RegRead(GetRootKey(Root) & "\" & KeyName))
Set RegObj = Nothing End Function Public Function RegDelete(Root As RootKeyNames, KeyName As String) As Boolean On Error GoTo Trap
Dim RegObj
Set RegObj = Create("W.Shell")
RegObj.RegDelete (GetRootKey(Root) & "\" & KeyName)
Set RegObj = Nothing
RegDelete = True Exit Function Trap:
RegDelete = False
End Function
