-
What is this parameter?
Code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow){ }
What is hInstance and hPrevInstance used for? It seems like it
would be like checking for App.PrevInstance but I don't think so.
I would use FindWindow to see if the app is running, but I am
just using CreateDialog and a resource file. It just seems like a
second hand way to check for the #32770 (Dialog) class and
window title.
Is there another way?
-
hInstance is a handle to the current instance of the program.
I believe hPrevInstance is only there for backwards compatibility. I hear the best way to do what you are trying to accomplish would be to use CreateMutex()
-
Right amac.
hInstance is used in things like LoadCursor or LoadIcon.
hPrevInstance is there for backward compability with Win16 and is always NULL now.
To find out if your app is running, try to open a named mutex, and if this fails, create one. (then it's the first instance, because any other would have been able to open the mutex)