📄 frmregistryeditor.frm
字号:
VERSION 5.00
Begin VB.Form frmRegistryEditor
Caption = "Registry Editor"
ClientHeight = 3795
ClientLeft = 60
ClientTop = 345
ClientWidth = 5775
LinkTopic = "Form1"
ScaleHeight = 3795
ScaleWidth = 5775
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "&Close"
Default = -1 'True
Height = 435
Left = 4320
TabIndex = 8
Top = 120
Width = 1335
End
Begin VB.CommandButton cmdSave
Caption = "&Save Setting"
Height = 435
Left = 4320
TabIndex = 9
Top = 1200
Width = 1335
End
Begin VB.TextBox txtSetting
Height = 315
Left = 900
TabIndex = 7
Top = 3360
Width = 3195
End
Begin VB.ListBox lstKeys
Height = 2010
Left = 900
TabIndex = 5
Top = 1200
Width = 3195
End
Begin VB.TextBox txtSection
Height = 315
Left = 1620
TabIndex = 3
Text = "Settings"
Top = 540
Width = 2475
End
Begin VB.TextBox txtApplicationName
Height = 315
Left = 1620
TabIndex = 1
Text = "VB6DBHT Chapter 11"
Top = 120
Width = 2475
End
Begin VB.Label lblSetting
Caption = "Se&tting:"
Height = 195
Left = 180
TabIndex = 6
Top = 3420
Width = 675
End
Begin VB.Label lblKeys
Caption = "&Key(s):"
Height = 195
Left = 180
TabIndex = 4
Top = 1200
Width = 555
End
Begin VB.Label lblSection
Caption = "Se&ction:"
Height = 195
Left = 180
TabIndex = 2
Top = 660
Width = 1455
End
Begin VB.Label lblApplicationName
Caption = "&Application Name:"
Height = 195
Left = 180
TabIndex = 0
Top = 180
Width = 1395
End
End
Attribute VB_Name = "frmRegistryEditor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' form level variable used to store keys and settings for desired
' application and section
Private m_vSettings As Variant
Private Sub Form_Load()
' initialize the application by populating the key list box
RepopulateKeys
End Sub
Private Sub lstKeys_Click()
' error message of choice when error has occurred obtaining setting
Const ERRMSG_INVALID_SETTING = "<ERROR>"
' set the txtSetting text box to the value of the key in the Registry
txtSetting = GetSetting(txtApplicationName, _
txtSection, _
lstKeys.Text, _
ERRMSG_INVALID_SETTING)
' if there was an error in the retrieval process, disable editing of
' the key's setting
If (txtSetting <> ERRMSG_INVALID_SETTING) Then
lstKeys.Enabled = True
txtSetting.Enabled = True
cmdSave.Enabled = True
End If
End Sub
Private Sub txtApplicationName_Change()
' repopulate the key list box when the application name has changed
RepopulateKeys
End Sub
Private Sub txtSection_Change()
' repopulate the key list box when the section name has changed
RepopulateKeys
End Sub
Private Sub cmdClose_Click()
' end the application
Unload Me
End Sub
Private Sub cmdSave_Click()
' save the selected key information from the desired information on
' the form
SaveSetting txtApplicationName, _
txtSection, _
lstKeys.Text, _
txtSetting
End Sub
Private Sub RepopulateKeys()
' if there is an error, goto the code labeled by ERR_RepopulateKeys
On Error GoTo ERR_RepopulateKeys:
Dim nCount As Integer
' errors that are expected to be encountered
Const ERR_INVALID_PROC_CALL = 5
Const ERR_TYPE_MISMATCH = 13
With lstKeys
' clear the listbox and setting text box
.Clear
txtSetting = ""
' disable editing functions
lstKeys.Enabled = False
txtSetting.Enabled = False
cmdSave.Enabled = False
' retrieve available keys for given application name and section
' this will cause an ERR_INVALID_PROC_CALL error if one of the text
' box controls are empty
m_vSettings = GetAllSettings(txtApplicationName, txtSection)
' add each setting to the key list box
' this will case an ERR_TYPE_MISMATCH error if there are no keys
' for the selected application and section names
For nCount = 0 To UBound(m_vSettings, 1)
.AddItem m_vSettings(nCount, 0)
Next nCount
' select the first item in the list box
.ListIndex = 0
End With
Exit Sub
ERR_RepopulateKeys:
With Err
Select Case .Number
' if the error is expected, do nothing but end the procedure
Case ERR_INVALID_PROC_CALL, ERR_TYPE_MISMATCH:
' unexpected error, display for the user
Case Else:
MsgBox "ERROR #" * .Number & ": " & .Description, _
vbExclamation, "ERROR"
End Select
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -