Results 1 to 26 of 26

Thread: [RESOLVED] Open several files using Command

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2013
    Posts
    113

    Resolved [RESOLVED] Open several files using Command

    Goodmorning

    I have built a program of which I wish only one instance opened at time. To do this, I used Mutex and related API calls:
    Code:
    Function Is2ndInstance() As Boolean
        Dim hMutex As Long
    
        hMutex = CreateMutex(ByVal 0&, 1, App.Title)
        If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then
            Is2ndInstance = True
            ReleaseMutex hMutex
            CloseHandle hMutex
        End If
    End Function
    
    Private Sub Form_Load()
        If Is2ndInstance Then End
        If Command <> "" Then
           'Code to open file
        End If
    End Sub
    Now there's my problem...

    I'm trying to give user the possibility to open files simply clicking on them and use the path stored into Command function to load them into my application. The first time user tries to open a file, it is successfully opened. But if he tries again, the Mutex doesn't allow and closes the second instance of the program without opening the file chosen.

    What can I do to open all files into the same instance of my application (avoiding my program is opened twice or more) ? Moreover I succeeded to use Command only if I select what program I want to open the file with (using the Open As... option in the contex Menu). In fact, the double click on the file didn't make anything useful. Why?

    Thank you all.
    Last edited by Fenrir; Mar 21st, 2013 at 05:08 AM.

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