Issues Pertaining to Single Instance Enforcement

Things you’d like to miss in the future...
Post Reply
twosixfoursix
Posts: 6
Joined: 03 Jun 2023 07:22

Issues Pertaining to Single Instance Enforcement

Post by twosixfoursix »

Hi there,

I haven't had the chance to update to newest version yet, but the following problems exist in upto version 27.00.0500.
  • It seems that the application is not creating a mutex to enforce single instance - so process launch commands of XYplorer in extremely rapid succession will result in launch of multiple instances even with "Allow multiple instances" disabled.
  • If I use something like an external hotkey program to launch XYplorer and it is already visible and in focus, it will open a new location passed in the program arguments in a new tab. But it will do this twice for some reason, resulting in 2 identical tab windows created on a single command.
Thank you kindly,

admin
Site Admin
Posts: 63953
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Issues Pertaining to Single Instance Enforcement

Post by admin »

Please try that with the latest 64-bit beta and report back: viewtopic.php?f=1&t=28739&sd=d
FAQ | XY News RSS | XY X - Forum users with the Windows version and screen scaling percentage in the Location field of their profiles get priority support.

twosixfoursix
Posts: 6
Joined: 03 Jun 2023 07:22

Re: Issues Pertaining to Single Instance Enforcement

Post by twosixfoursix »

Hmm... issue still persists on [27.90.0010 (64-bit)]. My OS: [Windows 10: Version 10.0.19045.6093].
Perhaps the following in main before anything else could help solve the issue.

Code: Select all

static HANDLE appmut = NULL;

int WINAPI wWinMain(_In_ HINSTANCE hinstance, _In_opt_ HINSTANCE prevhinstance, _In_ LPWSTR wargv, _In_ int cmdshow)
{
  appmut = CreateMutexW(NULL, TRUE, L"MyApplication");
  if(!appmut)
  {
    MessageBoxW(NULL, L"Was unable to initialize with mutex...", L"MyApplication", MB_OK);
    ExitProcess(0);
  }
  else if(GetLastError() == ERROR_ALREADY_EXISTS)
  {
    HWND myappinstance = FindWindowW(appName, appName);
    if(myappinstance)
    {
      SetForegroundWindow(myappinstance);
    }
    return FALSE;
  }
  // ...
}
And program arguments can be intercepted and passed to tab creation thread. And a `ReleaseMutex(appmut)` on `WM_CLOSE` of main XYPlorer window WndProc.

I think currently the single instance enforcement is just a window existence check of the harcoded name containing "XYplorer" and not a true mutex. So if the name of the binary changes, the enforcement becomes void. Obviously I am not changing the name of the exe all the time, I was just actively testing for issues as I recently started frequently using XYplorer again. It's a joy to use!

The dual tab creation also seems to persist, but something I have noticed is that it will only do that if the shortcut has VK_SHIFT combined with VK_MENU, which I am passing from AutoHotkey v2. Cannot understand why it happens. I think it might be because I configured AutoHotkey to actually create a new true process instead of just using the Run command (using the ahk author provided 'shell run' script), but I'm not sure.

Of course, the application is much more complex than this and I am unable to consider nor comprehend all other factors in the functioning - I'm just throwing out some ideas which I hope could aid in improving stability...

Thank you kindly,

admin
Site Admin
Posts: 63953
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Issues Pertaining to Single Instance Enforcement

Post by admin »

Okay, this looks like a very specific problem that will be dealt with later, once the 64-bit transformation has been completed.
FAQ | XY News RSS | XY X - Forum users with the Windows version and screen scaling percentage in the Location field of their profiles get priority support.

Post Reply