|
-
Jan 19th, 2005, 03:59 PM
#1
Thread Starter
Lively Member
Executing a method on the same app, other instance
Hello everybody,
I have an Application that allows one only instance. To accomplish this, I used this simple code on the Main() function.
Code:
Process[] runningProcesses = Process.GetProcessesByName(Application.ProductName.ToString());
if (runningProcesses.Length == 1){
Application.Run(new MainForm());
} else {
Application.Exit();
}
}
This is working indeed: when I run a second instance of my app, it silently kills itself. Well... almost too silently, that is.
Just before calling Application.Exit() I would like to restore a form (if needed) of the first, running instance. To do this, I'd have to call a method of the first instance from the second instance. How to do this? I found something on the internet about sendmessage and sendkeys but I got a bit puzzled.
If I could SendKeys a key to the first instance, that would be fine too: the method would be executed indirectly, triggered by a Context menuItem on my app trayicon.
I hope I made myswlf clear enough, thank you guys.
Last edited by BrightSoul; Jan 19th, 2005 at 04:17 PM.
- mo! I said MOOOOOOO!!
- ...yep, that's a cow, alright.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|