Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


URGENT : How to detect that an exe is still running on a remote machine

Posted on 2003-03-31
Medium Priority
Last Modified: 2013-11-20

I have an application that is connected remotely to a database server.

My application calls methods of the db server to get values.

The thing is that i need to know if the remote server is running, because if it does not run, my
application does not crash but it is lost.

So i need to know if the exe to which i am attached is still running, and if it is possible, if it is not in the Not responding state.

Please can you tell me how i can do a thing like this?

Question by:FMayis
LVL 86

Accepted Solution

jkr earned 2000 total points
ID: 8238178
Check out the 'pviewer' sample from MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmppviewer.asp). It pretty much resembles the 'PView.exe' that comes with VC++ and does it using the performance counter registry interface.
LVL 12

Expert Comment

ID: 8241274

  You will have to set up a heartbeat to the server. The best way to do this is to 'Connect' and 'Disconnect' every 60 seconds or so.

  This is as simple as starting a timer

  SetTimer ( 1,  60000);

  and Handling the WM_TIMER messge

  OnTimer ()
      KillTimer ( 1 );
      if ( !Connect ( ...db...  ) )
            AfxMessageBox ( "Server is down!" )
             Disconnect ( ..db... )
             StartTimer (1 ,60000 );

  Code above assumes 1 timer in your system.

  If the server is down Connect will timeout ... it may take a while to timeout. You can setup a thread that timesout in say 20 seconds if the default timeout is too long.


Author Comment

ID: 8243482
Thanks for both response.
The points will go to jkr.

It is much more what i was looking for.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

564 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