URGENT: Pass cmd line or other messages to active instance of application
Posted on 2006-05-23
I have an app that only allows one instance to be running at a time. I'm currently using ShowWindow & SetForegroundWindow in the Main entry point to detect the ealier process and then activate it (via the handle, etc) when found & then the 2nd instance shuts down. This all works well for a very long time now.
However, I now need to modify the load to accept command line args & also files (via a file association). Right now, everything works fine when there is no other instance open - both the cmd line args and/or the file when double clicked open the application, process the args, etc. My question is - if in the state where the app is already open, how do I pass the file info or other generic cmd line data to the first already opened instance before shutting the 2nd instance down?
Can this be done easily via SendNotifyMessage, or the like? Does anyone have any sample C# code that would do this. I'm using .NET 2.0 if that helps w/ a more elegant solution.
Thanks in advance.