-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathRegistryHelper.bas
More file actions
65 lines (43 loc) · 1.52 KB
/
RegistryHelper.bas
File metadata and controls
65 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Attribute VB_Name = "RegistryHelper"
'--------------------------------------------------------------------------------
' Component : RegistryHelper
' Project : ViOrb5
'
' Description: A lazy way to read and write registry changes (via the shell
' the shell object)
' TODO: Import and use the proper API Wrapper Registry wrapper
' class and ditch this disgusting shell object wrapper
'
' Modified :
'--------------------------------------------------------------------------------
Option Explicit
Private m_shellClass As Object
Public Sub DeleteKey(Value As String)
On Error Resume Next
RegClass.RegDelete Value
End Sub
Public Function ReadKeyInteger(Value As String, default As Long) As Long
On Error GoTo Handler
ReadKeyInteger = CLng(RegClass.RegRead(Value))
Exit Function
Handler:
ReadKeyInteger = default
End Function
Public Function ReadKeyString(Value As String) As String
On Error Resume Next
ReadKeyString = CStr(RegClass.RegRead(Value))
End Function
Public Sub WriteRegistryInteger(Folder As String, Value As Long)
On Error Resume Next
RegClass.RegWrite Folder, Value, "REG_DWORD"
End Sub
Public Sub WriteRegistryString(Folder As String, Value As String)
On Error Resume Next
RegClass.RegWrite Folder, Value
End Sub
Private Function RegClass() As Object
If m_shellClass Is Nothing Then
Set m_shellClass = CreateObject("wscript.shell")
End If
Set RegClass = m_shellClass
End Function