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