I'm currently automating an application at work using COM, and have an issue where anyone using my application has a problem if the original application is already open when my application runs. I know how to locate the process if it's open, but instead of having to worry about closing it, or working around it, etc., I want to try to use the existing application instead of opening a new one.
This is how I normally start the application in my automation program:
Designer.Application desApp = new Designer.Application();
Now I'm attempting to try and use the handle from an existing application:
Designer.Application desApp = (Designer.Application)((System.Diagnostics.Process.GetProcessesByName("Designer.exe")[0]).Handle)
(I know this doesn't work, since .Handle
returns an IntPtr
, but I'm using it as an example.)
Is there any way to accomplish this? How do I return a usable object if I know the handle/process?