0

hi guys....

i make a program with Dev-C++ ..... let say my program is already running now .... if i try to open it ... it show me a MessageBox or an output to tell me i can't run it when is already running

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by JGorard159
0

Create empty file when starting and delete at end, then refuse to start if the file exist. Problem is if your program crashes in middle, so be sure to have proper finally clean up which you run even program ended prematurely. I think in c++ it means the deletion of the lock file should be registered as atexit function.

Edited by pyTony

0

Cool story, bro.

Am I correct in inferring that you don't want that to happen? Because you neglected to ask any kind of question.

0

i appreciate your answer pyTony and deceptikon , i want my program show me a MessageBox or an output to tell which i can't run this program twice at the same time

0

In your program, add a function which creates a file when the application is run. Add another function to delete it when the application is closed.

Then, before initiatializing the application, check if the file exists. If it does, that means that another copy of the program is already running, so you can then display a message box.

Let me know if you need advice on specifically how to implement this.

Edited by JGorard159

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.