smarty February 2016

how to know form2 of other application is running

My question originates from here:

How do I know from one application that another application has an active form. Same machine (windows) running two application (a.exe and b.exe) both created in vb.net. How can a.exe know that b.exe form2 is open or not?

I know that b.exe is running via:

Public Function IsApplicationRunning(ByVal appName As String) As Process
   For Each aProcess in Process.GetProcesses()   
      If aProcess.ProcessName.StartsWith(appName, StringComparisong.CurrentCultureIgnoreCase) Then
         Return aProcess  
      End If
   Next
   Return Nothing
End Function

Answers


Nico Schertler February 2016

There is no direct way and Form2 needs to expose something that can be used to identify it (e.g. a certain title).

You already have the process handle. Then, check every window of that process. If you find a window that matches, it is very likely that the specified form is open. However, there is no guarantee because it could always be a window that looks similar (but that is based on another class).

Post Status

Asked in February 2016
Viewed 3,092 times
Voted 10
Answered 1 times

Search




Leave an answer