Results 1 to 5 of 5

Thread: How to access my application's Mutex through InstallScript?

  1. #1
    Join Date
    Sep 2005
    Posts
    17

    Question How to access my application's Mutex through InstallScript?

    Greetings,

    my application already creates a mutex object to prevent multiple instances of it from running.

    How do i access this mutex object from installscript such that i can detect that my application is running before uninstalling?

    regards
    Varun

  2. #2
    Join Date
    Oct 2001
    Location
    Here and there
    Posts
    16,243
    I haven't tried it, but perhaps see if you can you prototype and call the OpenMutex API function exported from Kernel32.dll?

  3. #3
    Join Date
    Jul 2003
    Location
    Austin, TX
    Posts
    4,403
    I did a Mutex implementation years ago when my application framework developer decided that he didn't llike using hidden windows and FindWindow() anymore. We implemented it in both directions though. When either the install or the application started it checked for a mutex and either terminated or created one. That way no one could try to start the application while the install was in progress.

    Unfortunatly I don't have the source code anymore.

    Here is a forum post from InstallSite in German. There is some source code, but I don't know if it works.

    http://forum.installsite.net/index.p...=0&#entry29650

    BTW you could also use WBEM to query the win32_process table to see if your app is running.
    Last edited by Christopher Painter; 10-14-2005 at 09:24 PM.
    Christopher Painter
    ISWIX, LLC.
    Visit iswix.com for contact information

  4. #4
    Join Date
    Oct 2001
    Location
    Here and there
    Posts
    16,243
    As a rough sketch, this seems to work (looking for the mutex created by a Windows Installer installation in deferred mode):
    Code:
    prototype HWND kernel32.OpenMutexA(NUMBER, BOOL, BYVAL STRING);
    
    function OnBegin( )
        HWND hMutex;
    begin
    
    hMutex = OpenMutexA(READ_CONTROL, FALSE, "_MSIExecute");
    
    /* // for debugging
    SprintfBox(INFORMATION, "hMutex",
        "hMutex: %d\nGetLastError: %s",
        hMutex, FormatMessage(Err.LastDllError));
    */
    
    if (hMutex) then
        MessageBox("Found the mutex...", INFORMATION);
        CloseHandle(hMutex);
    else
        MessageBox("Didn't find it...", INFORMATION);
    endif;
    
    end;

  5. #5
    Join Date
    Sep 2005
    Posts
    17

    Smile Task Achieved!!

    Thank u for your replies...

    I tried them, but somehow i couldn't find the mutex of the Running application through InstallScript(..i think there was some conflict with the mutex name).

    However i found a solution...
    I used the same function that my application uses... this function prevents multiple instances of my application from running.

    i embedded this function in a DLL.. and called this DLL from InstallScript..
    This works fine...

    Thanx again for ur help

    regards,
    Varun

Posting Permissions

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