Skip to main content
gamedev.net
🔒 Locked

Win32 Help

Started by Mad_Koder 7 replies 1k views
Original Post
Mad_Koder
Mad_Koder
I have read several tutorials on Win32 and I still do nto understand it. Basically I dont understand what certain parameters do (the tutorials acts is if you should know basically what it does, but I dont know the details) like: HINSTANCE hInstance " Handle to the programs executable module (the .exe file in memory) " I have no clue what in the hell that means, seriously. Am I trying to get into more depth then needed; for example, it says on one parameter: HINSTANCE hPrevInstance "Always NULL for Win32 programs. " and it doesnt give anything else, should I know what this parameter means and does in depth?
Dont need one.... i'm so cool, dont ask me just do what you do..... meet me in the trap its going down....
Colin Jeanne
Colin Jeanne
An HINSTANCE is just a unique identifier for the instance of program. Each program has its own HINSTANCE. If you have two copies of your program running then you'll have two different HINSTANCES.

Normally, all you'll do with it is give it to functions like LoadImage() when loading an image from a resource. In this case it tells LoadImage() to grab the resources from your program.

The second HINSTANCE parameter from WinMain() used to give you the HINSTANCE of another instance of your program (if one was running). It was useful if you wanted to see if multiple copies of your program was running (since each copy of a program has its own unique HINSTANCE). Unfortunately this is a relic of the Win16 days and is meaningless in Win32. You can ignore this parameter.
Verg
Verg
Quote:
Original post by Mad_Koder
I have read several tutorials on Win32 and I still do nto understand it. Basically I dont understand what certain parameters do (the tutorials acts is if you should know basically what it does, but I dont know the details) like:

HINSTANCE hInstance

" Handle to the programs executable module (the .exe file in memory) "

I have no clue what in the hell that means, seriously


In addition to what Colin said, the "hInstance" you are given in WinMain() is just a pointer to your code (machine code) in memory. Usually for Win32 proggies that's at 0x04000000.


Mad_Koder
Mad_Koder
Thanks, but im so confused with all the stuff you have to learn and the parameters in win32 and specail stuff, any suggestions to keeping cool and not giveing up on it because thats about where I'm at?
Dont need one.... i'm so cool, dont ask me just do what you do..... meet me in the trap its going down....
CrazyCdn
CrazyCdn
Not to sound rude by maybe stick to console programs until you understand the language and OS better then move up to Win32 when you have a better grasp of the language you are using (likely C/C++ right?). I had a friend in your shoes, he tried to go from crawling to sprinting and fell on his face and refused to listen. Now 5 years later (he stopped coding for 5 years) he is back at it and taking it slow but making great progress.

Anyways, best of luck to you.
"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin
tksuoran
tksuoran
You will need the HINSTANCE for some win32 functions. So when you get the value from win32 main or dll entry, you probably should save it somewhere in case you want to do things like window creation.
mikeman
mikeman
Quote:
Original post by Mad_Koder
Thanks, but im so confused with all the stuff you have to learn and the parameters in win32 and specail stuff, any suggestions to keeping cool and not giveing up on it because thats about where I'm at?


Don't browse the MSDN or tutorials and read random stuff when you don't actually need them, at least not now that you're a beginner. That makes it hard to remember them. They sit in your brain like a pile of disconnected information with no special meaning. It's ok if you don't understand everything. When it will become necessary to learn them, you will. When you would reach to the point where you need to learn to create a window or load a library, you would see that HINSTANCE is required. You would then look it up, see what it is and how it is used, and it would all "click". That's how you proceed.

And of course, you only have to learn what the functions in the Win32 API do and how to use them, not memorize all their names and arguments. Nobody does that. That's what IntelliSense and reference manuals are for, so you can look them up.
Colin Jeanne
Colin Jeanne
Quote:
Original post by Mad_Koder
Thanks, but im so confused with all the stuff you have to learn and the parameters in win32 and specail stuff, any suggestions to keeping cool and not giveing up on it because thats about where I'm at?

You learn best by using. After you use the Win32 API a lot you'll begin to understand it, remember what structures, functions, interfaces, etc. exist, and how to use them.

Reading is good to help prepare yourself for what's coming but it wont teach you. For programming, doing is learning.

As others have said, dont try to memorize. I work at Microsoft and I need to refer to the documentation all the time. That's why it's there. Focus on understanding the concepts.
LessBread
LessBread
Quote:
Original post by Verg
Usually for Win32 proggies that's at 0x04000000.


0x00400000 actually.

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.