Hi people!!
I would like to allow the user to run only one instance of the executable.
Considering that the site may have pop-ups? What is the best way to do this?
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
How to allow only one instance?
- danicarla2
- Posts: 19
- Joined: Mon Oct 01, 2018 6:01 pm
- Location: Brazil
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to allow only one instance?
Hi
You can use a named mutex :
https://www.swissdelphicenter.ch/en/showcode.php?id=42
You would only have to check the mutex in the main process and not in other CEF subprocesses.
If you use the same EXE for all processes then the pseudo-code in your DPR file would look like this :
If you use a different EXE for the subprocesses then you would only add the "CheckMyMutex" and "DestroyMyMutex" calls in the main DPR and not in the DPR for the subprocesses.
You can use a named mutex :
https://www.swissdelphicenter.ch/en/showcode.php?id=42
You would only have to check the mutex in the main process and not in other CEF subprocesses.
If you use the same EXE for all processes then the pseudo-code in your DPR file would look like this :
Code: Select all
CreateGlobalCEFApp;
if GlobalCEFApp.StartMainProcess then
begin
if CheckMyMutex then
begin
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end;
DestroyMyMutex;
end;
DestroyGlobalCEFApp;