Click here to Skip to main content
16,007,687 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to create another formview? Pin
steven_wong3-May-05 21:33
steven_wong3-May-05 21:33 
AnswerRe: how to create another formview? Pin
liquid_4-May-05 10:07
liquid_4-May-05 10:07 
GeneralRe: how to create another formview? Pin
steven_wong4-May-05 15:05
steven_wong4-May-05 15:05 
GeneralRe: how to create another formview? Pin
liquid_7-May-05 1:04
liquid_7-May-05 1:04 
GeneralRe: how to create another formview? Pin
steven_wong7-May-05 5:14
steven_wong7-May-05 5:14 
GeneralRestrict my application to one instance only Pin
Rajesh_K_Sharma3-May-05 21:19
Rajesh_K_Sharma3-May-05 21:19 
GeneralRe: Restrict my application to one instance only Pin
ThatsAlok3-May-05 21:33
ThatsAlok3-May-05 21:33 
GeneralRe: Restrict my application to one instance only Pin
Claudio Grazioli3-May-05 21:38
Claudio Grazioli3-May-05 21:38 
I would not do it by setting a value in the registry. Imagine this situation:


  1. Instance1 starts and sets the Value "running=1" in the registry.
  2. Instance2 starts and reads the value in the registry -> "running=1" -> quit.
  3. Instance1 exits and resets the value "running=0"
  4. Instance3 starts. "running=0" -> runs and sets "running=1".
  5. Everything fine for now. But lets go further:

  6. Instance3 crashes or is killed by a user. Registry key is not reset. "running=1"!!!
  7. Instance4 starts. checks for registry key -> "running=1" -> quits!!!

So now the application cannot be started again until someone manually resets the registry key. Not nice!

Better solutions:
  • use a named mutex
  • enumerate all running processes and look if your's is already running
  • Search for something like Single Instance Application VC++ or Singletion Application VC++ here on CodeProject or on Google and you'll find several examples how to solve this.


    Claudio
    Claudio's Website
    Hommingberger Gepardenforelle
    GeneralRe: Restrict my application to one instance only Pin
    Aamir Butt4-May-05 0:58
    Aamir Butt4-May-05 0:58 
    GeneralRe: Restrict my application to one instance only Pin
    Claudio Grazioli4-May-05 1:24
    Claudio Grazioli4-May-05 1:24 
    GeneralRe: Restrict my application to one instance only Pin
    Aamir Butt4-May-05 19:08
    Aamir Butt4-May-05 19:08 
    GeneralRe: Restrict my application to one instance only Pin
    David Crow4-May-05 3:31
    David Crow4-May-05 3:31 
    GeneralRe: Restrict my application to one instance only Pin
    itkid4-May-05 20:54
    itkid4-May-05 20:54 
    GeneralMenu Pin
    Anonymous3-May-05 20:48
    Anonymous3-May-05 20:48 
    GeneralRe: Menu Pin
    ThomasABBE4-May-05 1:45
    ThomasABBE4-May-05 1:45 
    GeneralMultiple http-requests are stuck Pin
    meremortal3-May-05 20:44
    meremortal3-May-05 20:44 
    GeneralRe: Multiple http-requests are stuck Pin
    Ravi Bhavnani4-May-05 7:33
    professionalRavi Bhavnani4-May-05 7:33 
    GeneralRe: Multiple http-requests are stuck Pin
    meremortal9-May-05 10:39
    meremortal9-May-05 10:39 
    GeneralRe: Multiple http-requests are stuck Pin
    Ravi Bhavnani9-May-05 10:52
    professionalRavi Bhavnani9-May-05 10:52 
    GeneralRe: Multiple http-requests are stuck Pin
    geo_m12-May-05 9:10
    geo_m12-May-05 9:10 
    GeneralRe: Multiple http-requests are stuck Pin
    meremortal12-May-05 10:10
    meremortal12-May-05 10:10 
    GeneralRe: Multiple http-requests are stuck Pin
    geo_m13-May-05 7:49
    geo_m13-May-05 7:49 
    GeneralJava Launcher Pin
    vyjesh3-May-05 20:34
    vyjesh3-May-05 20:34 
    GeneralRe: Java Launcher Pin
    S. Senthil Kumar3-May-05 20:37
    S. Senthil Kumar3-May-05 20:37 
    Generala question on heap..... Pin
    namaskaaram3-May-05 20:14
    namaskaaram3-May-05 20:14 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.