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
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
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.
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.
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
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.