📄 modsettingmanager.bas
字号:
Attribute VB_Name = "modSettingManager"
Function RegQueryStringValue(ByVal hKey As Long, ByVal strValueName As String)
Dim lResult As Long
Dim lValueType As Long
Dim strBuf As String
Dim lDataBufSize As Long
On Error GoTo 0
lResult = RegQueryValueEx(hKey, strValueName, 0&, lValueType, ByVal 0&, lDataBufSize)
If lResult = ERROR_SUCCESS Then
If lValueType = REG_SZ Then
strBuf = String(lDataBufSize, " ")
lResult = RegQueryValueEx(hKey, strValueName, 0&, 0&, ByVal strBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
RegQueryStringValue = StripTerminator(strBuf)
End If
End If
End If
End Function
Public Function GetString(hKey As Long, strpath As String, strvalue As String)
Dim keyhand&
Dim datatype&
R = RegOpenKey(hKey, strpath, keyhand&)
GetString = RegQueryStringValue(keyhand&, strvalue)
R = RegCloseKey(keyhand&)
End Function
Public Sub savestring(hKey As Long, strpath As String, strvalue As String, strdata As String)
Dim keyhand&
R = RegCreateKey(hKey, strpath, keyhand&)
R = RegSetValueEx(keyhand&, strvalue, 0, REG_SZ, ByVal strdata, Len(strdata))
R = RegCloseKey(keyhand&)
End Sub
Public Sub Delstring(hKey As Long, strpath As String, sKey As String)
Dim keyhand&
R = RegOpenKey(hKey, strpath, keyhand&)
R = RegDeleteValue(keyhand&, sKey)
R = RegCloseKey(keyhand&)
End Sub
Public Sub SaveSet(AppName As String, Section As String, Key As Variant, Value As Variant)
savestring HKEY_CURRENT_USER, "Software\" & App.CompanyName & "\" & AppName & "\" & Section, CStr(Key), CStr(Value)
End Sub
Public Function GetSet(AppName As String, Section As String, Key As Variant, Optional Default As Variant) As Variant
GetSet = GetString(HKEY_CURRENT_USER, "Software\" & App.CompanyName & "\" & AppName & "\" & Section, CStr(Key))
If GetSet = "" Then GetSet = Default
End Function
Public Function DelSet(AppName As String, Section As String, Key As Variant) As Variant
Delstring HKEY_CURRENT_USER, "Software\" & App.CompanyName & "\" & AppName & "\" & Section, CStr(Key)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -