private
sub
command2_click()
select
case
text1.text
case
"form1"
form1.show
case
"form2"
form2.show
case
else
mgsbox
"没有这个窗体名"
end
select
end
sub
前提是把所有关的窗体名都要知道
呵呵
Function CheckApplicationIsRun(ByVal szExeFileName As String) As BooleanOn Error GoTo Err
Dim WMI
Dim Obj
Dim Objs
CheckApplicationIsRun = False
Set WMI = GetObject("WinMgmts:")
Set Objs = WMI.InstancesOf("Win32_Process")
For Each Obj In Objs
If InStr(UCase(szExeFileName), UCase(Obj.Description)) <>0 Then
CheckApplicationIsRun = True
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
Exit Function
End If
Next
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
Exit Function
Err:
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
End Function Private Sub Form_Load()
If CheckApplicationIsRun("abc.exe") = True Then
Else
Shell "C:\abc.exe" End If双进程互保,不懂追问
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)