How to make your process only could be excuted once?

bro
i have a question !
how to make your process only could be opened once ?
it only show the process window that you opened before when you clicked twice .exe?

That's not possible in general.

What many programs are doing instead is looking for the window associated with process and activate it if said window is found.

This process is racy: on a heavily loaded Windows XP you can open dozens of “clock” windows if you click on taskbar furiously enough.

hey Dude !
what should i do if i want to implement what you mentioned? (What many programs are doing instead is looking for the window associated with process and activate it if said window is found.)I DO NOT KNOW how toimplement wit rust ! PLZ HELP ME ! THX

When I last needed that Rust haven't existed thus I have no idea how to do that specifically in Rust.

Today, apparently, the best way is to create a Mutex (names should start with Local\ to ensure that it's unique per user session, not globally-unique, if you need globally-unique you need Global\).

This StackOverflow answer lists more possibilities, but I'm afraid you'll need to explore the question more: maybe there are even appropriate crate, but it looks like no one who did that recently is here.

The general idea is to, still, organize some kind of dialogue between first and second processes. Browsers do that, maybe you can find that code in Chromium or Firefox code.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.