Results 1 to 4 of 4

Thread: Check for Running Instance of an application

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    34

    Check for Running Instance of an application

    Hi,
    I'm trying to keep from running multiple instances of the rundll32.exe (open with dialog.). I've read alot of topics on the forum and they all seem to be about app.prevInstance, but can't find one dealing with outside applications. Can anybody point me in the right direction? Thanks alot, Rick

    Shell ("rundll32.exe shell32.dll,OpenAs_RunDLL " & strFullName)

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Try this...

    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2.  
    3. Private Sub Command1_Click()
    4.     Dim WinWnd As Long
    5.     WinWnd = FindWindow(vbNullString, strFullName)
    6.     If WinWnd = 0 Then
    7.        MsgBox "Application Not Running"
    8.     Else
    9.        MsgBox "Application Already Running"
    10.     End If
    11. End Sub

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Regarding App.PrevInstance
    That is only for your own current application.

    So in your Main() or Form_Load() Sub you would check for App.PrevInstance, and that would tell you if this app is already running or not.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    34

    Talking

    Thanks for the replies. Thanks Hack, that is perfect!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width