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

📄 registry editor.frm

📁 标题:读和写注册表文件的例子 用visualbasic编的
💻 FRM
字号:
VERSION 4.00
Begin VB.Form Registry 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Registry Editor"
   ClientHeight    =   3255
   ClientLeft      =   2130
   ClientTop       =   1440
   ClientWidth     =   4575
   Height          =   3660
   Icon            =   "Registry Editor.frx":0000
   Left            =   2070
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3255
   ScaleWidth      =   4575
   Top             =   1095
   Width           =   4695
   Begin VB.Frame Keys 
      Caption         =   "Keys"
      Height          =   975
      Left            =   120
      TabIndex        =   9
      Top             =   2160
      Width           =   3015
      Begin VB.CommandButton Deletekeys 
         Caption         =   "&Delete Key"
         Height          =   375
         Left            =   1560
         TabIndex        =   11
         Top             =   360
         Width           =   1215
      End
      Begin VB.CommandButton Createkeys 
         Caption         =   "&Create Key"
         Height          =   375
         Left            =   240
         TabIndex        =   10
         Top             =   360
         Width           =   1215
      End
   End
   Begin VB.Frame Write 
      Caption         =   "Write"
      Height          =   975
      Left            =   120
      TabIndex        =   5
      Top             =   0
      Width           =   4335
      Begin VB.CommandButton Writestring 
         Caption         =   "Write String"
         Height          =   375
         Left            =   240
         TabIndex        =   8
         Top             =   360
         Width           =   1215
      End
      Begin VB.CommandButton Writebinary 
         Caption         =   "Write Binary"
         Height          =   375
         Left            =   1560
         TabIndex        =   7
         Top             =   360
         Width           =   1215
      End
      Begin VB.CommandButton Writedword 
         Caption         =   "Write Dword"
         Height          =   375
         Left            =   2880
         TabIndex        =   6
         Top             =   360
         Width           =   1215
      End
   End
   Begin VB.Frame Read 
      Caption         =   "Read"
      Height          =   975
      Left            =   120
      TabIndex        =   1
      Top             =   1080
      Width           =   4335
      Begin VB.CommandButton Readdword 
         Caption         =   "Read Dword"
         Height          =   375
         Left            =   2880
         TabIndex        =   4
         Top             =   360
         Width           =   1215
      End
      Begin VB.CommandButton Readbinary 
         Caption         =   "Read Binary"
         Height          =   375
         Left            =   1560
         TabIndex        =   3
         Top             =   360
         Width           =   1215
      End
      Begin VB.CommandButton Readstring 
         Caption         =   "Read String"
         Height          =   375
         Left            =   240
         TabIndex        =   2
         Top             =   360
         Width           =   1215
      End
   End
   Begin VB.CommandButton Cancel 
      Caption         =   "&Cancel"
      Height          =   375
      Left            =   3480
      TabIndex        =   0
      Top             =   2760
      Width           =   975
   End
End
Attribute VB_Name = "Registry"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Private Sub Cancel_Click()

Unload Me 'exit the program

End Sub


Private Sub Createkey_Click()

rtn=CreateKey "HKEY_CLASSES_ROOT"

End Sub


Private Sub Createkeys_Click()

'This creates a new key in the users registry.

CreateKey "HKEY_LOCAL_MACHINE\Registry Editor"

MsgBox "A Key has been created in you system registry at:" + Chr(10) + Chr(10) + "HKEY_LOCAL_MACHINE\Registry Demo"

End Sub

Private Sub Deletekeys_Click()

'This deletes a key in the users registry. All sub keys and entrys under
'this key will also be deleted.

DeleteKey "HKEY_LOCAL_MACHINE\Registry Editor"

MsgBox "A Key has been deleted in you system registry at:" + Chr(10) + Chr(10) + "HKEY_LOCAL_MACHINE\Registry Demo"

End Sub

Private Sub Form_Load()

Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2 'centre the form on the screen

'This project was downloaded from
'
'http://www.brianharper.demon.co.uk/
'
'Please use this project and all of its source code however you want.
'
'UNZIPPING
'To unzip the project files you will need a 32Bit unzipper program that
'can handle long file names. If you have a latest copy of Winzip installed
'on your system then you may use that. If you however dont have a copy,
'then visit my web site, go into the files section and from there you can
'click on the Winzip link to goto their site and download a copy of the
'program. By doing this you will now beable to unzip the project files
'retaining their proper long file names.
'Once upzipped, load up your copy of Visual Basic and goto
'File/Open Project. Locate the project files to where ever you unzipped
'them, then click Open. The project files will be loaded and are now ready
'for use.
'
'THE PROJECT
'Well....This project can and is the most valuable of them all. Most if not
'all of Windows programs to this day, read and write the the users system
'registry to store data in some kind of way. I have tried to make this
'process as simple as possible by putting each function into its own
'seperate precedure. I myself think it is quite simple once you know what
'your actually trying to do. There are three different types of entrys that
'can be written to or read from. The most common of the three is String
'values. String values can hold any text or number. The other two you might
'never use, but are handy to know  you have access to theme.
'
'Binary entrys are that little bit more complicated as these are all to do
'with bytes and hexadecimal. I, myself really arnt all that sure on these
'types of entrys, but hopefully you will learn as time goes on.
'
'For some reason but I dont really know why, when you call the function,
'DeleteKey, it doesnt seem to work. I am looking into this, but there
'doesnt seem to be anything wronge with the code.
'
'NOTES
'I have only provided the necessary project files with the zip. This keeps
'the size of the zip files down to a minimum and enables me to upload more
'prjects files to my site.
'
'I hope you find the project usful in what ever you are programming. I
'have tried to write out a small explanation of what each line of code
'does in the project, although most of it is pretty simple to understand.
'
'If you find any bugs in the code then please dont hesitate to Email me and
'I will get back to you as soon as possible. If you however need help on a
'different matter concerning Visual Basic then please please Email me as
'I like to here from people and here what they are programming.
'
'My Email address is:
'Brian@brianharper.demon.co.uk
'
'My web site is:
'http://www.brianharper.demon.co.uk/
'
'Please visit my web site and find many other useful projects like this.
'

End Sub

Private Sub Readbinary_Click()

'This calls the GetBinaryValue function. This function reads a Binary
'value from the users registry. The first part of the function gives the
'full path of the location at which the key is located. The second part is
'the name of the entry. The MsgBox returns the value from the registry. If
'the value counld not be found, then "Error" will be returned and displayed
'in the Msgbox.

rtn = GetBinaryValue("HKEY_LOCAL_MACHINE", "Binary Value")
If rtn = Chr$(&H1) + Chr$(&H2) + Chr$(&H3) + Chr$(&H4) Then
   MsgBox "The value was returned successfully..."
End If

End Sub

Private Sub Readdword_Click()

'This calls the GetDWORDValue function. This function reads a DWORD
'value from the users registry. The first part of the function gives the
'full path of the location at which the key is located. The second part is
'the name of the entry. The MsgBox returns the value from the registry. If
'the value counld not be found, then "Error" will be returned and displayed
'in the Msgbox.

MsgBox GetDWORDValue("HKEY_LOCAL_MACHINE", "DWORD Value")

End Sub

Private Sub Readstring_Click()

'This calls the GetStringValue function. This function reads a String
'value from the users registry. The first part of the function gives the
'full path of the location at which the key is located. The second part is
'the name of the entry. The MsgBox returns the value from the registry. If
'the value counld not be found, then "Error" will be returned and displayed
'in the Msgbox.
'
'If you need to read the default value fron a key, then leave the name of
'the the entry blank (""). This will then, not look for a string, but will
'return the default value a key.

MsgBox GetStringValue("HKEY_LOCAL_MACHINE", "String Value")

End Sub


Private Sub Writebinary_Click()

'This calls the SetBinaryValue function. This function writes a Binary
'value to the users registry. The first part of the function gives the full
'path of the location at which the key is located. The second part is the
'name of the entry. The third and final part of the function is the value
'at which is to be written to the entry.
'
'Binary values are slightly different to string and DWORD values such that
'they work in bytes. It can get quite complicated when dealing with these,
'but hopefully you should very rarly use them. To write a hexadecimal value
'of "00 00 00 00" in the registry, you have to use the Chr$(&H0)+Chr$(&H0)
'+Chr$(&H0)+Chr$(&H0).
'
'If the entry you are writting to in the regsitry does not exist, then a
'new entry will be created with the name and value specified.

SetBinaryValue "HKEY_LOCAL_MACHINE", "Binary Value", Chr$(&H1) + Chr$(&H2) + Chr$(&H3) + Chr$(&H4)

MsgBox "A Binary Value has been created in you system registry at:" + Chr(10) + Chr(10) + "HKEY_LOCAL_MACHINE" + Chr(10) + Chr(10) + "The Binary was called ""Binary Value"" and the value written was:" + Chr(10) + Chr(10) + "01 02 03 04"

End Sub

Private Sub Writedword_Click()

'This calls the SetDWORDValue function. This function writes a DWORD
'value to the users registry. The first part of the function gives the full
'path of the location at which the key is located. The second part is the
'name of the DWORD. The third and final part of the function is the value
'at which is to be written to the DWORD value.
'
'If the entry you are writting to in the regsitry does not exist, then a
'new entry will be created with the name and value specified.

SetDWORDValue "HKEY_LOCAL_MACHINE", "DWORD Value", "1"

MsgBox "A DWORD Value has been created in you system registry at:" + Chr(10) + Chr(10) + "HKEY_LOCAL_MACHINE" + Chr(10) + Chr(10) + "The DWORD was called ""Dword Value"" and the value written was:" + Chr(10) + Chr(10) + "1"

End Sub

Private Sub Writestring_Click()

'This calls the SetStringValue function. This function writes a String
'value to the users registry. The first part of the function gives the full
'path of the location at which the key is located. The second part is the
'name of the entry. The third and final part of the function is the value
'at which is to be written to the entry.
'
'If the entry you are writting to in the regsitry does not exist, then a
'new entry will be created with the name and value specified.

SetStringValue "HKEY_LOCAL_MACHINE", "String Value", "Hello Visual Basic programmer"

MsgBox "A String Value has been created in you system registry at:" + Chr(10) + Chr(10) + "HKEY_LOCAL_MACHINE" + Chr(10) + Chr(10) + "The String was called ""String Value"" and the value written was:" + Chr(10) + Chr(10) + "Hello Registry"

End Sub


⌨️ 快捷键说明

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