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. HINSTANCE hPrevious

HINSTANCE hPrevious

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 4 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.
  • S Offline
    S Offline
    slah
    wrote on last edited by
    #1

    The second argument of the winmain is HINSTANCE hPrevious. this is the handle to the previous instance of the application. how we can use it to control the creation of the application instance so that only one instance should be running at one time.

    N L D 3 Replies Last reply
    0
    • S slah

      The second argument of the winmain is HINSTANCE hPrevious. this is the handle to the previous instance of the application. how we can use it to control the creation of the application instance so that only one instance should be running at one time.

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      In 32 bit windows this HINSTANCE is dummy and only there for backward compatibility. For maintaining single-instance apps, use a mutex. Nish


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

      1 Reply Last reply
      0
      • S slah

        The second argument of the winmain is HINSTANCE hPrevious. this is the handle to the previous instance of the application. how we can use it to control the creation of the application instance so that only one instance should be running at one time.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Yes, this parameter in a 32-bits application is always set to NULL. To test an instance of an application, you can for example test the existence of a Windows Class. For instance, if you main window class name is "MyClassName", you can use the function FindWindow ("MyClassName", NULL). If this function return not NULL, then another instance of your application is running. Thks in advance! Appstmd

        1 Reply Last reply
        0
        • S slah

          The second argument of the winmain is HINSTANCE hPrevious. this is the handle to the previous instance of the application. how we can use it to control the creation of the application instance so that only one instance should be running at one time.

          D Offline
          D Offline
          Daniel Lohmann
          wrote on last edited by
          #4

          The hPrevious parameter is useless in Win32, it is only there for backward compatibility. For an in-detail discussion of how to perform a correct instance check (the usual recommended ways to use FindWindow/Mutex lead to unexpected results :(( ), look at this article. Some ready-to-use code is available here, but I strongly recommend to read the above article first. -- Daniel Lohmann http://www.losoft.de

          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