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

📄 设置或取消程序的开机运行.frm

📁 Windows API函数,希望大伙有用哦
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H8000000B&
   Caption         =   "Form1"
   ClientHeight    =   1755
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5625
   LinkTopic       =   "Form1"
   ScaleHeight     =   1755
   ScaleWidth      =   5625
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "重新设置"
      Height          =   345
      Left            =   3060
      TabIndex        =   6
      Top             =   1230
      Width           =   975
   End
   Begin VB.CommandButton Command2 
      Caption         =   "返回系统"
      Height          =   345
      Left            =   4080
      TabIndex        =   1
      Top             =   1230
      Width           =   975
   End
   Begin VB.Frame Frame1 
      Appearance      =   0  'Flat
      BackColor       =   &H8000000B&
      Caption         =   "运行方式选择"
      ForeColor       =   &H80000008&
      Height          =   885
      Left            =   390
      TabIndex        =   0
      Top             =   180
      Width           =   4755
      Begin VB.CheckBox Check2 
         Caption         =   "Check2"
         Height          =   225
         Left            =   2430
         TabIndex        =   5
         Top             =   360
         Width           =   225
      End
      Begin VB.CheckBox Check1 
         Caption         =   "Check1"
         Height          =   225
         Left            =   270
         TabIndex        =   4
         Top             =   360
         Width           =   225
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "禁止开机运行本程序"
         Height          =   180
         Left            =   2820
         TabIndex        =   3
         Top             =   390
         Width           =   1620
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "允许开机运行本程序"
         Height          =   180
         Left            =   570
         TabIndex        =   2
         Top             =   390
         Width           =   1620
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
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 RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
    Const REG_SZ = 1
    Const HKEY_LOCAL_MACHINE = &H80000002
Dim hKey As Long
Private Sub Check1_Click()
Dim A1 As String
 If Check1.Value = 1 Then
   Check2.Enabled = False
     RegCreateKey HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey
     A1 = "F:\AAA\设置或取消程序的开机运行.exe"
     RegSetValueEx hKey, "AS1", 0&, REG_SZ, A1, 2 * Len(A1)
   Else
   Check2.Enabled = True
 End If
End Sub
Private Sub Check2_Click()
Dim A1 As String
If Check2.Value = 1 Then
    Check1.Enabled = False
     RegCreateKey HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey
     RegDeleteValue hKey, "AS1"
   Else
   Check1.Enabled = True
End If
End Sub
Private Sub Command1_Click()
    Check1.Value = 0
    Check2.Value = 0
    Check1.Enabled = True
    Check2.Enabled = True
End Sub
Private Sub Command2_Click()
    RegCloseKey HKEY_LOCAL_MACHINE
    Unload Me
    End
End Sub

⌨️ 快捷键说明

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