Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private isRun As Boolean
Private Sub Command1_Click()
If Not isRun Then
Shell "Calc.exe", vbNormalNoFocus
isRun = True
End If
End Sub
Private Sub Form_Load()
Timer1.Interval = 10
End Sub
Private Sub Timer1_Timer()
Dim isFindHwnd As Long
isFindHwnd = FindWindow(vbNullString, "计算器")
If isFindHwnd > 0 Then
isRun = True
Else
isRun = False
End If
End Sub