Issues Pertaining to Single Instance Enforcement

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
twosixfoursix
Posts: 9
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: 66431
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

twosixfoursix
Posts: 9
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: 66431
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.

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

Re: Issues Pertaining to Single Instance Enforcement

Post by twosixfoursix »

Hi again,

This issue has been fixed as of XYplorer Version: 28.30.1400 (x64).

I apologize - the issue actually still persists in that single app enforcement is still a hard string check of the name "XYPlorer". I just forgot the behavior since I hadn't used the application in a while. However, as long as the binary name remains XYPlorer.exe, this is a non-issue.

Many thanks,

Post Reply