?
Solved

Runnng applications

Posted on 2005-03-21
6
Medium Priority
?
126 Views
Last Modified: 2010-04-05
I have a delphi application that as part of its process calla a VB.Net executable from a timer. Is it possible to check if the application is already running as part of the timer function as it is imperative only one instance of the vb app runs at a time. If so can sombody give me an example of how to achieve this

Many thanks
0
Comment
Question by:Paul-Brooks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 17

Assisted Solution

by:mokule
mokule earned 400 total points
ID: 13591915
// in Your case it should be on timer event not button

procedure TForm1.Button1Click(Sender: TObject);
begin
  if FindWindow(nil,'VBWindowCaption') > 0 then
    Label1.Caption := 'Window find'
  else
    Label1.Caption := 'Window not find';
end;

mokule
0
 
LVL 17

Expert Comment

by:geobul
ID: 13592017
It would be much more correct if that check (one instance only) was done by the VB app itself. Then you wouldn't need to worry about that.

Regards, Geo
0
 

Author Comment

by:Paul-Brooks
ID: 13592098
Geo
I totally agree with your comment but i am even more inept with VB than i am with Delphi so was hoping it would just as well this way round
Regards
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Molando
ID: 13592584
As Mokule said. Use findwindow.

If you knew the class name, I would throw that param in (first param), but if the title of the app was constant, then use that.

0
 
LVL 17

Assisted Solution

by:geobul
geobul earned 400 total points
ID: 13592689
Then mokule's suggestion can help you (if the VB app has a window and doesn't change its window caption during the execution). Just use it like the following in the timer event:

begin
  if FindWindow(nil,'VBWindowCaption') = 0 then Run_The_VB_App_Here;
end;

Don't use small Timer.Interval value. That value should be, for instance, twice bigger than the amount of time necessary for the VB app to run (create its main window), i.e. if the app runs in 2 seconds then set Timer.Interval to 4000. That way it will work correctly on slower machines.

Regards, Geo
0
 
LVL 9

Accepted Solution

by:
ezraa earned 1200 total points
ID: 13592861
In your vb app you can run this function on startup:

   Public Sub ExitIfExistingInstance()
        If Process.GetProcessesByName _
          (Process.GetCurrentProcess.ProcessName).Length > 1 Then
           Application.Exit()
        End If
    End Sub
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question