Announcement

Collapse
No announcement yet.

How to check if a program is running

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to check if a program is running

    We have a serverapplication (not a service) which has to run when clients run their erp-application. There is no check in the erp-application if the serverapplication is running. The application is being started on the console of the server, but sometimes it is aborted. I want to check on the server if the application is running before we import orderlines from another database.
    How can I add a function in my CC-program, that imports the orderlines into the ERP-database, which checks if the consoleprogram (win 32-bit) is running.

    Thanks for your tip!

  • #2
    That can be done with a mutex. Search here on that.

    When the server starts up it can create a mutex; when the client wants to send a request to the server, it checks if the mutex exists. If it does, the server is running. If it does not, the server is not running, and the client can if desired launch the server and wait for it to be ready.

    Note: you may have to use the "Global" prefix in your mutex name eg..
    Code:
    $MUTEX_NAME = "Global\Program_Mutex_Name"
    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Mutexes can be used if you wrote the application to check for. If not, you can use EnumProcesses to check if a certain process is running.

      Kind regards
      Eddy

      Comment


      • #4
        Well, there are other ways to check, but they all depend on HOW the client makes a request of the server...

        eg ..
        • If by DDE and the DDE Service is not found, the server is not running.
        • If by TCP and the server doesn't answer... probably means the server is not running
        • If by named pipe or mailslot and the pipe or mailslot cannot be opened by the client, the server is not running.

        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Originally posted by Michael Mattias View Post
          Note: you may have to use the "Global" prefix in your mutex name eg..
          Code:
          $MUTEX_NAME = "Global\Program_Mutex_Name"
          MCM
          Good to see you are getting up to date with namespaces. Was also pleasantly surprised to see in another post your comments about the fixed width of numeric characters in proportional fonts. It is hard for us old dogs keeping track of all the new tricks
          Cheers
          John

          Comment

          Working...
          X