How to control uniq application instance by some GUI control component? lazarus / 21-General ---------------------------------------------------------------------- tersion · 2021-03-15 11:09 I need to control unique instance of app using, for example, checkbox control on main form. If checkbox is checked - only one instance of app is allowed. When I uncheck this checkbox - multiple instances of app is allowed. I've tried using Enabled property of UniqueInstance component for this purpose, but with no luck. ---------------------------------------------------------------------- trev · 2021-03-15 11:10 Operating system? I've used this successfully on FreeBSD, Linux and Windows: https://arbinada.com/en/node/1426 ---------------------------------------------------------------------- tersion · 2021-03-15 15:28 Quote from: trev on March 15, 2021, 12:10:52 pmOperating system? I've used this successfully on FreeBSD, Linux and Windows: https://arbinada.com/en/node/1426 OS is only Windows. Thanks for the link. I read it and if I understand correctly, this method based on creating temporary file as a mutex. I started searching for more examples of mutex method and found this (link to forum in russian language) (based on WinAPI). So I used example mention there. But if I would write something cross-platform, I'll keep your example on mind. trev, thanks for help! ---------------------------------------------------------------------- avra · 2021-03-15 17:04 https://wiki.freepascal.org/UniqueInstance ---------------------------------------------------------------------- Fred vS · 2021-03-15 17:14 https://github.com/fredvs/runonce_postit ---------------------------------------------------------------------- Fred vS · 2021-03-15 17:41 Hello. Quotefor example, checkbox control on main form. If checkbox is checked - only one instance of app is allowed. When I uncheck this checkbox - multiple instances of app is allowed. Hum, in that way it will be more tricky. At first look, the simplest is to use a dummy file created by the main form when checkbox is checked. And delete it when checkbox is un-checked. When a new instance is created, it will see if the dummy file exists, if yes then new instance = application.terminate else continue loading the new instance. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}  cthreads,  {$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, Unit1 , sysutils  { you can add units after this }; {$R *.res}       begin  if not fileexists('dummy') then  begin  RequireDerivedFormResource:=True;  Application.Scaled:=True;  Application.Initialize;  Application.CreateForm(TForm1, Form1);  Application.Run;  end;end. Fre;D ---------------------------------------------------------------------- ASBzone · 2021-03-15 21:03 Quote from: tersion on March 15, 2021, 12:09:58 pmI need to control unique instance of app using, for example, checkbox control on main form. If checkbox is checked - only one instance of app is allowed. When I uncheck this checkbox - multiple instances of app is allowed. I've tried using Enabled property of UniqueInstance component for this purpose, but with no luck. What is the anticipated or desired behavior if you already have multiple instances running, and then you check that checkbox?