Windows自带的"计算器"程序,可以同时有多个在运行。我希望我的程序运行以后,再启动的时候它会提示,如何实现?

解决方案 »

  1.   

    If App.PrevInstance <> 0 Then
        ..........
        ..........
    End If
      

  2.   

    Private Sub Form_Load()
    If App.PrevInstance Then a = MsgBox("程序已打开,是否关闭其中一个?", vbYesNo)
    If a = 6 Then End
    End Sub
      

  3.   

    If App.PrevInstance <> 0 Then
        msgbox("程序已在运行")
    End If
      

  4.   

    "App.PrevInstance"如果他为真则程序已经运行!
      

  5.   

    If App.PrevInstance = True Then
       msgbox "程序已被多次运行,按下确定键将关闭"
       end
    EndIf
      

  6.   

    '局部模块参数
    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