I'm using C#.NET to launch and control a Delphi-written executable. The Delphi application has a COM interface.
I've imported the Delphi executable -- we'll call it DelphiApp.exe -- into Visual Studio as a resource.
The following C# code works -- if no other instance of DelphiApp.exe is running:
DelphiApp.DelphiAppClass da = new DelphiAppClass();
da.DoStuff(1, 3, 4);
If an instance of DelphiApp.exe is running, the above code will "take over" one of the instances, which is not what I want. When I declare a new DelphiAppClass()
, I always want it to be a new application instance.
I've tried several workarounds -- like launching a new DelphiApp process if one already exists -- but I can't seem to find the proper way to handle this.
Any suggestions?