⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 Visual Basic6 读写注册表程序包括删除注册表
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "注册"
   ClientHeight    =   2310
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7305
   LinkTopic       =   "Form1"
   ScaleHeight     =   2310
   ScaleWidth      =   7305
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command7 
      Caption         =   "校验码"
      Height          =   375
      Left            =   3720
      TabIndex        =   11
      Top             =   1200
      Width           =   1335
   End
   Begin VB.TextBox Text5 
      Height          =   495
      Left            =   720
      TabIndex        =   10
      Top             =   1080
      Width           =   2775
   End
   Begin VB.CommandButton Command6 
      Caption         =   "取注册码"
      Height          =   495
      Left            =   6240
      TabIndex        =   9
      Top             =   3480
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.TextBox Text4 
      Height          =   375
      Left            =   720
      TabIndex        =   8
      Top             =   480
      Width           =   2775
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   1560
      TabIndex        =   7
      Text            =   "Text3"
      Top             =   4080
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.CommandButton Command5 
      Caption         =   "Command5"
      Height          =   495
      Left            =   600
      TabIndex        =   6
      Top             =   4560
      Visible         =   0   'False
      Width           =   1575
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   120
      TabIndex        =   5
      Text            =   "Text2"
      Top             =   4080
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.CommandButton Command4 
      Caption         =   "产生随机数"
      Height          =   375
      Left            =   720
      TabIndex        =   4
      Top             =   3360
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.CommandButton Command3 
      Caption         =   "删除"
      Height          =   375
      Left            =   5280
      TabIndex        =   3
      Top             =   1680
      Width           =   1935
   End
   Begin VB.CommandButton Command2 
      Caption         =   "读"
      Height          =   495
      Left            =   5280
      TabIndex        =   2
      Top             =   840
      Width           =   1935
   End
   Begin VB.CommandButton Command1 
      Caption         =   "写入注册表"
      Height          =   375
      Left            =   3360
      TabIndex        =   1
      Top             =   2760
      Visible         =   0   'False
      Width           =   1815
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   600
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   2640
      Visible         =   0   'False
      Width           =   1935
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
        SaveSetting "MyApp", "User", "Name", Text1
        'SaveSetting "MyApp", "User", "Company", Text2
        MsgBox "您的信息已成功保存!"

End Sub
'新建一个窗体,在窗体里添加三个按钮,两个文本输入框,完成后打开代码窗口,
'将以下内容填入对应代码段里,运行就可以操作注册表了。
'Private Sub cmdSave_Click()        '这是添加注册表项的代码
'
'        '将两个文本框中的内容分别赋给MyApp下User区中Name和Company
'        SaveSetting "MyApp", "User", "Name", txtName
'        SaveSetting "MyApp", "User", "Company", txtCompany
'        MsgBox "您的信息已成功保存!"
'
'End Sub
'
'Private Sub cmdFind_Click()       '这是查找并显示注册表项的代码
'
'        '查找MyApp下User区中Name和Company的设置值并显示
'   If GetSetting("MyApp", "User", "Name") = "" Then
'            MsgBox "在注册表中未找到该项内容!"
'        Else
'            MsgBox "您的姓名是:" & GetSetting("MyApp", "User", "Name") & Chr(13) & Chr(10) & _
'           "您的公司是:" & GetSetting("MyApp", "User", "Company")
'   End If
'End Sub
'
'Private Sub cmdDelete_Click()    '这是删除注册表项的代码
'
'     '删除MyApp下的User区域及其下的所有注册表项
'     DeleteSetting "MyApp", "User"
'     MsgBox "该项设置已删除。"
'
'End Sub
'


Private Sub Command2_Click()
  If GetSetting("MyApp", "User", "Name") = "" Then
            MsgBox "在注册表中未找到该项内容!"
        Else
            MsgBox "您的姓名是:" & GetSetting("MyApp", "User", "Name")
   End If
End Sub

Private Sub Command3_Click()
  DeleteSetting "MyApp", "User"
     MsgBox "该项设置已删除。"
End Sub

Private Sub Command4_Click()
 Text1.Text = Int(Rnd() * (999999 - 100000 + 1) + 100000)
End Sub

Private Sub Command5_Click()
  Text2.Text = Hex(Val(Text1.Text))
  Text3.Text = Oct(Val(Text1.Text))
End Sub

Private Sub Command6_Click()
  Dim str1
  Dim str2
  Dim str3
  Dim lstr
  Dim a As Date
  a = Time
  lstr = Right(a, 1) + 1
  Text5.Text = lstr

  str1 = Left((Int(Rnd() * (999 - 100 + 1) + 100)) * lstr, 3)
  str2 = Left((Int(Rnd() * (999 - 100 + 1) + 100)) * lstr, 3)
  str2 = Hex(Val(str2))
  Select Case Len(str2)
    Case 1
      str2 = str2 + "00"
    Case 2
      str2 = str2 + "0"
    Case 3 = str2
  End Select
  str3 = Left((Int(Rnd(lstr) * (999 - 100 + 1) + 100)) * lstr, 3)
  Text4.Text = str1 & str2 & str3
End Sub

Private Sub Command7_Click()
  Dim str1
  Dim str2
  Dim str3
  str1 = Left(Text4.Text, 3)
  str1 = Left(Hex(Val(str1)) & str1, 3)
  str2 = Mid(Text4.Text, 4, 3)
  str2 = Left(CStr(Val("&H" & str2)), 3)
  str3 = Right(Text4.Text, 3)
  str3 = Val(str3) + Val(Oct(str3))
  str3 = Left(str3, 3)
  Text5.Text = str1 & str2 & str3
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -