vb里如何判断一个程序是否已经运行,有人知道吗?

解决方案 »

  1.   

    Public Function IsFileOpen(sFile As Variant) As Boolean
        Dim fFile As Integer
        Dim msg As String
        fFile = FreeFile()
        On Error GoTo ErrOpen
        Open sFile For Binary Lock Read Write As fFile
          Close fFile
        Exit Function
    ErrOpen:    If Err.Number <> 70 Then
            msg = "Error # " & Err.Number & " was generated by " _
               & Err.Source & Chr(13) & Err.Description
            MsgBox msg, , "Error", Err.HelpFile, Err.HelpContext
        Else
            IsFileOpen = True
        End If
    End Function
      

  2.   

    ....用 直接去读你要判断的文件, 用上面的函数, 开启了就会返回 True  IsFileOpen = True
      

  3.   

    hot1kang1(许仙-http://3q2008.Com) 真高人也,已运行的程序,我们写它就会出错,捕捉此错误,就可以知道这个程序是否运行了