Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I switch to a .NET winforms app from Delphi 1

Status
Not open for further replies.

bbegley

Programmer
Apr 29, 2002
228
US
We have two applications that were originally written in Delphi. Users regularly switch back and forth between the applications, and we provided a button to do so. We knew the ApplicationClass (TApplication) and the name of the window, so using FindWindow to switch was no problem.

We have moved one of the apps to C# (Visual Studio, per mgt. demand), and will eventually translate the other one. The C# can find the delphi app using the System.Diagnostics classes.
What we can not do is switch to an open instance of the C# app.

Using the Winsight tool, I can see the application class. This class does not always appear to be the same for the C# app. I have seen both WindowsForms10.Window.8.app3 and WindowsForms10.Window.8.appa7.


We do know the process name for the C# app. Does anyone know a way to switch to that process from the delphi app with just that information?



Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
By the way, I am using Delphi 6, and I get an external exception (0008?) when I try to close the handle of whatever window I find.

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Using window handles to talk between applications is becoming more and more prone to failure as the OSes evolve.

My best advise is to rewrite both apps to use a pipe/socket/memory file to do the talk.

As a quick and dirty fix, make your apps save the window handles in the registry at start and delete the keys at end (or set the value to zero). You can use mutexes to be sure the apps are really running (as an app crashing/killed by the user can leave the key loaded with an erroneous value, but the mutex will be gone).

If you can't close the handle, send a user message to the window to have it closing itself in an orderly way.

HTH.
buho (A).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top