Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. limit app to one instance

limit app to one instance

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiotutorialquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    big_denny_200
    wrote on last edited by
    #1

    hi all:) i have a mfc dialog application in Visual Studio 2005. How to limit it to one instance ? thank you.

    T PJ ArendsP D T 4 Replies Last reply
    0
    • B big_denny_200

      hi all:) i have a mfc dialog application in Visual Studio 2005. How to limit it to one instance ? thank you.

      T Offline
      T Offline
      tbrake
      wrote on last edited by
      #2

      Hi A common way to handle one instance is using an identifier BOOL CMyApp::InitInstance() { HANDLE hMutex = CreateMutex (NULL, TRUE, "MY APP IDENTIFICATION"); if (GetLastError() == ERROR_ALREADY_EXISTS) { AfxMessageBox("Alreay running!"); return FALSE; } if(hMutex) ReleaseMutex (hMutex); ... } CU Timen

      1 Reply Last reply
      0
      • B big_denny_200

        hi all:) i have a mfc dialog application in Visual Studio 2005. How to limit it to one instance ? thank you.

        PJ ArendsP Offline
        PJ ArendsP Offline
        PJ Arends
        wrote on last edited by
        #3

        There are lots of CP articles on the subject. Do a search. http://www.codeproject.com/info/search.asp?target=single+instance&st=kw&qm=all[^]


        You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

        Within you lies the power for good; Use it!

        1 Reply Last reply
        0
        • B big_denny_200

          hi all:) i have a mfc dialog application in Visual Studio 2005. How to limit it to one instance ? thank you.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          See here.


          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

          "We will be known forever by the tracks we leave." - Native American Proverb

          1 Reply Last reply
          0
          • B big_denny_200

            hi all:) i have a mfc dialog application in Visual Studio 2005. How to limit it to one instance ? thank you.

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            big_denny_200 wrote:

            How to limit it to one instance ?

            http://www.codeproject.com/cpp/csingleinst.asp[^]

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups