If App.PrevInstance <> 0 Then .......... .......... End If
Private Sub Form_Load() If App.PrevInstance Then a = MsgBox("程序已打开,是否关闭其中一个?", vbYesNo) If a = 6 Then End End Sub
If App.PrevInstance <> 0 Then msgbox("程序已在运行") End If
"App.PrevInstance"如果他为真则程序已经运行!
If App.PrevInstance = True Then msgbox "程序已被多次运行,按下确定键将关闭" end EndIf
'局部模块参数 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Public Sub Main() If App.PrevInstance = False Then '要打开的程序 Else Dim hw As Long, hs As Long hw = FindWindow(vbNullString, "应用程序窗口名") hs = ShowWindow(hw, 9) End If end sub
..........
..........
End If
If App.PrevInstance Then a = MsgBox("程序已打开,是否关闭其中一个?", vbYesNo)
If a = 6 Then End
End Sub
msgbox("程序已在运行")
End If
msgbox "程序已被多次运行,按下确定键将关闭"
end
EndIf
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Sub Main()
If App.PrevInstance = False Then
'要打开的程序
Else
Dim hw As Long, hs As Long
hw = FindWindow(vbNullString, "应用程序窗口名")
hs = ShowWindow(hw, 9)
End If
end sub