Announcement

Collapse
No announcement yet.

Ensuring only one instance of a program – how?

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

  • #21
    What was wrong with my suggestion

    Comment


    • #22
      >What was wrong with my suggestion

      Nothing. Testing a file either for 'existence' or 'in use' is a perfectly valid way to check if a program is running.

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

      Comment


      • #23
        Mike, your suggestion was fine.

        Comment


        • #24
          To make it more useful, the locked file can contain the computer name and time the file was locked.
          Makes it much easier on a network to see who is holding up production.

          Comment


          • #25
            The file solution is awfully straightforward.... but if you don't need the panache points......
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #26
              Synonyms
              charisma, dash, flare, style, swagger, élan, flair, flourish, verve, vigor,

              Comment


              • #27
                >There can't be. You prevented this from happening.

                You are assuming that this type of code will be used only to determine if your own application is already running.

                The scope of the code I wrote was to cover detection of multiple instances of selected applications, SQL Query analyser for example, that I had no control over the launching of; but might still cause my application problems when it is trying to apply tsql scripts to one or more databases.

                Comment


                • #28
                  Re your version 2 Erik

                  ' This version will is based on the file size. It will kill instances with the
                  ' same file size even if the file has been renamed by someone.
                  .....
                  .....
                  .....
                  IF DirDataVar.FileSizeLow = FileSize AND lngR <> kk THEN ' kill other files of same size even if renamed.

                  Before killing I'd be inclined to make sure that they have the same SHA1 hash value.
                  Last edited by David Roberts; 7 Dec 2008, 02:46 PM. Reason: Spelling

                  Comment


                  • #29
                    You are assuming that this type of code will be used only to determine if your own application is already running.
                    Actually, I was assuming it would be used to determine if an instance of THIS program was running... which was, after all, the original question.

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

                    Comment

                    Working...
                    X