📄 在开始快捷菜单添加菜单项.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1290
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 1290
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 1560
TabIndex = 1
Top = 720
Width = 1155
End
Begin VB.CheckBox Check1
Caption = "将本程序添加到“开始”按钮的快捷菜单"
Height = 315
Left = 240
TabIndex = 0
Top = 180
Width = 3975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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 ' Note that if you declare the lpData parameter as String, you must pass it By Value.
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 Const REG_SZ = 1 ' Unicode nul terminated string
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Sub Command1_Click()
Dim hKey As Long
Dim iRet As Long
Dim strRunCmd As String
Dim strMenuName As String
strRunCmd = App.Path & IIf(Len(App.Path) > 3, "\" & App.EXEName & ".exe", App.EXEName & ".exe")
strMenuName = "我的应用程序"
Select Case Check1.Value
Case 1
iRet = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Classes\Directory\shell\abcd", hKey)
iRet = RegSetValueEx(hKey, "", 0&, REG_SZ, ByVal strMenuName, Len(strMenuName) * 2)
iRet = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Classes\Directory\shell\abcd\command", hKey)
iRet = RegSetValueEx(hKey, "", 0&, REG_SZ, ByVal strRunCmd, Len(strRunCmd) * 2)
iRet = RegCloseKey(hKey)
Case 0
iRet = RegDeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Classes\Directory\shell\abcd\command")
iRet = RegDeleteKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Classes\Directory\shell\abcd")
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -