📄 shellwat.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "用Shell控制别的软件"
ClientHeight = 1440
ClientLeft = 1140
ClientTop = 1515
ClientWidth = 5250
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 1440
ScaleWidth = 5250
Begin VB.CommandButton Command1
Caption = "打开记事本程序"
Height = 435
Left = 1440
TabIndex = 0
Top = 840
Width = 1815
End
Begin VB.Label Label1
Caption = "单击下面按钮将会打开记事本程序,当关闭记事本程序时,会弹出“程序运行完成”的消息框。"
Height = 495
Left = 360
TabIndex = 1
Top = 120
Width = 4635
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' Shows how to shell to another program, and wait until it finishes
' before continuing.
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Const INFINITE = -1&
Private Const SYNCHRONIZE = &H100000
Private Sub Command1_Click()
Dim iTask As Long, ret As Long, pHandle As Long
iTask = Shell("notepad.exe", vbNormalFocus)
pHandle = OpenProcess(SYNCHRONIZE, False, iTask)
ret = WaitForSingleObject(pHandle, INFINITE)
ret = CloseHandle(pHandle)
MsgBox "程序运行完成!"
End Sub
Private Sub Form_Load()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -