|
-
Mar 12th, 2002, 06:02 PM
#1
Thread Starter
Frenzied Member
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?
-
Mar 12th, 2002, 08:10 PM
#2
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()
-
Mar 13th, 2002, 09:06 AM
#3
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)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|