IsOnlyInstance

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • IsOnlyInstance

      In the initialization I noticed that I could run more than one copy of the application. It looks as though it should be FindWindow(NULL, gameTitle) instead. That way it looks for the window name rather than the class name. I could be wrong, but I have a second edition book with it coded the same way and it looks backwards to me.
      Elegant code is finding the simplest solutions to the most complex puzzles.
    • RE: IsOnlyInstance

      I don't think it matters since gameTitle is used for both. Using the class name is more common since the window name sometimes changes with the configuration.

      You can run more than one copy of the game in debug mode. Check out the comment in the call to IsOnlyInstance():

      Source Code

      1. #ifndef _DEBUG
      2. // Note - it can be really useful to debug network code to have
      3. // more than one instance of the game up at one time - so
      4. // feel free to comment these lines in or out as you wish!
      5. if (!IsOnlyInstance(VGetGameTitle()))
      6. return false;
      7. #endif


      -Rez
    • RE: IsOnlyInstance

      Okay, thanks for the reply. Great book, by the way. I like how it focuses on how everything fits together rather than going into too much detail on the code that might change every time a new version of DirectX comes out.
      Elegant code is finding the simplest solutions to the most complex puzzles.