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

📄 form1.frm

📁 用vb编的一个关闭和启用注册表程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "保护注册表"
   ClientHeight    =   1950
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5010
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   1950
   ScaleWidth      =   5010
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command2 
      Caption         =   "允许使用"
      Height          =   870
      Left            =   2685
      Picture         =   "Form1.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   1
      ToolTipText     =   "允许使用注册表编辑器"
      Top             =   480
      Width           =   1395
   End
   Begin VB.CommandButton Command1 
      Caption         =   "禁止使用"
      Height          =   870
      Left            =   555
      Picture         =   "Form1.frx":337F
      Style           =   1  'Graphical
      TabIndex        =   0
      ToolTipText     =   "禁止使用注册表编辑器"
      Top             =   480
      Width           =   1395
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const REG_DWORD As Long = 4
Const HKEY_CURRENT_USER = &H80000001
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private Sub Command1_Click()   '禁止使用注册表编辑器
  Dim ret1 As Long
  ret1 = RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", hKey)
  If ret1 = 0 Then
     RegSetValueEx hKey, "DisableRegistryTools", "0", REG_DWORD, 1, 4
  Else
    RegCreateKey HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", hKey
    RegSetValueEx hKey, "DisableRegistryTools", "0", REG_DWORD, 1, 4
  End If
  MsgBox "设置成功,重新启动计算机后生效!", 64, "明日图书"
  RegCloseKey HKEY_CURRENT_USER
End Sub

Private Sub Command2_Click()   '允许使用注册表编辑器
  ret1 = RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies", hKey)
  If ret1 = 0 Then
    RegDeleteKey hKey, "System"
    MsgBox "设置成功,重新启动计算机后生效!", 64, "明日图书"
  End If
  RegCloseKey HKEY_CURRENT_USER
End Sub

⌨️ 快捷键说明

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