form1.frm

来自「本文件包含200个visual baisc实例」· FRM 代码 · 共 122 行

FRM
122
字号
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form form1 
   Caption         =   "将程序设置成自动执行的程序"
   ClientHeight    =   2025
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6285
   LinkTopic       =   "Form2"
   ScaleHeight     =   2025
   ScaleWidth      =   6285
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton Command2 
      Caption         =   "..."
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   330
      Left            =   5610
      TabIndex        =   4
      TabStop         =   0   'False
      Top             =   585
      Width           =   495
   End
   Begin VB.CommandButton Command3 
      Caption         =   "退出"
      Height          =   540
      Left            =   3285
      TabIndex        =   2
      Top             =   1245
      Width           =   1500
   End
   Begin VB.TextBox Text1 
      Height          =   345
      Left            =   930
      TabIndex        =   1
      Top             =   570
      Width           =   5190
   End
   Begin VB.CommandButton Command1 
      Caption         =   "设置"
      Height          =   540
      Left            =   1785
      TabIndex        =   0
      Top             =   1245
      Width           =   1500
   End
   Begin MSComDlg.CommonDialog CmD1 
      Left            =   810
      Top             =   1335
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "程序:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   165
      TabIndex        =   3
      Top             =   570
      Width           =   840
   End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 Option Explicit
 Const REG_SZ As Long = 1
 Const HKEY_LOCAL_MACHINE = &H80000002

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey 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 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 Sub Form_Load()
  Text1.Text = App.Path & "\设置程序自动开机启动.exe"
End Sub
Private Sub Command1_Click()
  Dim hKey As Long
  Dim myexe As String
  Dim myint As Integer
  myint = Len(Text1.Text) - InStrRev(Text1.Text, "\")
  myexe = Right(Text1.Text, myint)
  If Text1.Text <> "" Then
     RegCreateKey HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey
     RegSetValueEx hKey, myexe, 0, REG_SZ, ByVal Text1.Text, 13
     RegCloseKey hKey
  End If
End Sub
Private Sub Command2_Click()
  CmD1.DialogTitle = "选择文件"
  CmD1.Filter = "exe|*.exe"
  CmD1.ShowOpen
  If Len(CmD1.FileName) Then
    Text1.Text = CmD1.FileName
  End If
End Sub
Private Sub Command3_Click()
  End
End Sub


⌨️ 快捷键说明

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