Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2007

Tip: Looking for answers? Try searching our database.

Starting another application within an application using start.pro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JDH - 16 Jul 2007 23:36 GMT
Hello, I am using VB.Net VS 2005.  I have two Windows applications. The first
application has a command button with the following code that starts the 2nd
application.

      Dim oStartInfo As ProcessStartInfo = New ProcessStartInfo
      oStartInfo.FileName = "H:\RevTrak\RevTrak.exe"
      Process.Start(oStartInfo)

This code works ok; however, there are two problems that I cannot resolve.

1. Each time the command button is clicked, another instance of the
executable program (RevTrak.exe) is started, which I do not want. I only want
one instance of the program to be running.

2. If the program is already running, I do not want to start another
instance of the program. I want the currently running program's window to get
focus (or to activate the window).

Thanks for your help.
Peter Duniho - 17 Jul 2007 03:14 GMT
> [...]
> 1. Each time the command button is clicked, another instance of the
[quoted text clipped - 6 lines]
> to get
> focus (or to activate the window).

I don't know the specific calls you need to make, but I can at least give  
you some advice as to where to look and what you're trying to do.

Before you do the Process.Start() code, you need to search the top-level  
window list or, preferably, the process list (so you can actually check  
the executable name rather than the window name), to see if the  
application you wanted started has already been started.  If you don't  
find the application, start the process as normal.

Otherwise, once you have found the window (either directly or via the  
process), then you need to activate it.  As long as your application is  
already the foreground application, this should bring the other process to  
the foreground.  If not, you will likely just get a task bar notification  
(flashing task bar item).

Pete
JDH - 18 Jul 2007 22:40 GMT
Thanks Pete.  Once I determine the program is already running, how do I
activate the program (so it has focus)?  Is there a WIN32 API function call
for this?

JDH


> > [...]
> > 1. Each time the command button is clicked, another instance of the
[quoted text clipped - 23 lines]
>
> Pete
Peter Duniho - 19 Jul 2007 00:18 GMT
> Thanks Pete.  Once I determine the program is already running, how do I
> activate the program (so it has focus)?  Is there a WIN32 API function  
> call for this?

Yes.  I used to know the name of it off the top of my head, but can't  
think of it right now.  Probably something like ActivateWindow() or  
something else along those lines.

Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.