flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] Run Program only one instance?

Author
Thread Post new topic Reply to topic
ly47



Joined: 24 Sep 2010
Posts: 28
ly47 07 Oct 2019, 13:39
Hi
Some programs can be opened several times...
and some programs you can open only 1 window,if you try to open again
you will get your program activated.
And that what I need.
Every program I write can be opened multi windows.
How I have to code that my exe file will be opened only once ?
Thanks
ly


Description:
Filesize: 124.19 KB
Viewed: 6284 Time(s)

multi win.jpg


Post 07 Oct 2019, 13:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20489
Location: In your JS exploiting you and your system
revolution 07 Oct 2019, 13:51
The usual method is to use a Mutex.

The first instance creates the Mutex. Each subsequent instance will fail to create the Mutex since it already exists.

Then you can send a message to the first instance to give it whatever information it might need from the command line.
Post 07 Oct 2019, 13:51
View user's profile Send private message Visit poster's website Reply with quote
ly47



Joined: 24 Sep 2010
Posts: 28
ly47 07 Oct 2019, 14:12
Hi
Thanks
But I do not know what is Mutex,
any simple short example please...
Thanks again
ly
Post 07 Oct 2019, 14:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20489
Location: In your JS exploiting you and your system
revolution 07 Oct 2019, 14:50
Post 07 Oct 2019, 14:50
View user's profile Send private message Visit poster's website Reply with quote
ly47



Joined: 24 Sep 2010
Posts: 28
ly47 07 Oct 2019, 15:01
Hi
Thanks
I have to learn this...
and it will take time
ly
Post 07 Oct 2019, 15:01
View user's profile Send private message Reply with quote
ly47



Joined: 24 Sep 2010
Posts: 28
ly47 08 Oct 2019, 00:59
Hi Again
Solved.
attached simple win template with CreateMutex
and it works.
ly


Description:
Download
Filename: TEMPLATE_mutex.ASM
Filesize: 2.42 KB
Downloaded: 571 Time(s)

Post 08 Oct 2019, 00:59
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 23 Oct 2019, 00:37
Mutex will fail if program crashes before release of handle.
I use FindWindow() with class name and null window name...
Post 23 Oct 2019, 00:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.