How to make a program run only once. It could be any "hello world" program. It should say smth. (error, 2 console windows are not allowed) if the program is already running and shut down the second console window. (the first concole window should stay where it is)
sirko 0 Newbie Poster
Recommended Answers
Jump to PostOr this one:
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string proc = Process.GetCurrentProcess().ProcessName; Process[] processes = Process.GetProcessesByName(proc); if (processes.Length > 1) { MessageBox.Show("Application already running...", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { } }
All 4 Replies
Momerath 1,327 Nearly a Senior Poster Featured Poster
agugglez 0 Newbie Poster
Mitja Bonca 557 Nearly a Posting Maven
Rynkadink 18 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.