How to learn Win32

Hello! I'm getting into windows programming and I'm wondering what is the best way to learn Win32 API and if you recommend any tutorials (maybe youtube) or books or something like that to learn it.
Win32 is really fun for me and I love it, but everybody's not like me. So your mileage may vary.

Its old. Most old timers learned it by reading and studying Charles Petzold's "Programming Windows" book. I think they stopped publishing the book just a couple years ago, but it can be bought used I believe. I do think they may still publish a digital version though.

Nowadays there are a lot of tutorials on the web. I've even written one myself, but I believe one of the more popular ones has been the Forger's Win32 Tutorial. Google for that and you'll surely find it.

Here's something to e very careful about, as it causes beginners a lot of trouble. If you use Visual Studio Express that development environment predefines the UNICODE macro so all character strings use wide characters. You'll run into problems with the Forger's Win32 Tutorial as all its examples use ansi strings. Its as easy as can be to fix but when you don't know what you're doing you get stuck.

Another populal development environment is Code::Blocks. That doesn't predefine the character set, so you won't run into the problem described above. If I were you I'd get both.

If you've just learned C++ and haven't used C much the Win32 Api will shake you up somewhat. Its essentially object oriented programming a la C. Function Pointers are used heavily. If you aren't too familiar with them you should study up on them.

My tutorial is here ...

http://www.jose.it-berater.org/smfforum/index.php?topic=3389.0
Last edited on
as freddie said, Charles Petzold's "Programming Windows" book is probably a defacto bible for win32 programming. You dont need the latest version, the API is pretty stable.
http://www.charlespetzold.com/books.html

if you choose NOT to use visual studio you will need a Windows SDK (software development kit) so you have the .h files and libraries for linking.

in my opinion visual studio is the bet way to go, the debugger is excellent and it supports lots of other goodies out of the box like source code cross referencing.

it can feel slow going, theres a lot of code required to do the simplest things, and many functions have a lot of parameters, code can look messy very quickly if you don't take care.

Also, its a C api, Microsoft provide C++ wrappers for it which is the MFC library. Contrary to its name its not so much a class library but more a framework.

Microsofts online reference for win32 is excellent and it is all well documented.
if you choose NOT to use visual studio you will need a Windows SDK (software development kit) so you have the .h files and libraries for linking.

I never had to get a WinSDK. (Using Orwell Dev-C++ w/ MinGW 4.8.1 32-bit)
then where did you get your header files from? AKAIK they dont ship with windows.

edit...
ah, after researching that, i see that there are now alternative implementation of the header files. Last i looked everyone needed the the sdk. Thanks for the update.
Last edited on
You can download and install the Windows 7 SDK and that will provide you with everything you need to create Windows programs except an IDE. In other words, you would need to use Notepad or whatever to write your code, and compile at the command line.

If you install Visual Studio Express the SDK is installed along with that, so you would be able to use the IDE and still do command line compiling.

If you install Code::Blocks and choose the option with both the IDE and the MinGW port of the GCC compiler suite, then you'll have everything just as above with Visual Studio Express.

You can also download the GCC Compiler Suite byitself too, and use whatever editor you want. I basically do all of the above.

One thing I hadn't mentioned is that Charles Petzold's example programs from his book "Programming Windows" should be available for download somewhere on his website. That way, if you could come up with a used copy of his book without the disk, you could still get the programs. There are a lot of them - some long - and they are excellent.

You know, when you think about it, this may be the only programming technique 'out there' where you can take 20 year old program code and compile it and get it to work on today's systems. That might tell you something.
Last edited on
If Win32 is not the best option, then which API do you recommend using for windows programming and graphics

If Win32 is not the best option, then which API do you recommend using for windows programming and graphics


For me its definitely the best option. I've tried all the others and don't like them. I suppose it depends on what your interests and goals are. Some like the multi-platform support of QT or wxWidgets. For me, all I'm really interested in is desktop Windows for application programming, and I take pride in the fact that my apps are as small and as fast as they possibly can be. That's why I do pure Api code, and create my own class wrappers here and there as I see fit. In terms of graphics, GDI is deprecated, but there are a couple alternatives out there to replace it if you need to.
The WinAPI files that ships with a lot of compilers are incomplete and or out of date, they are there to provide the basics but trust me that very few things are more annoying then missing some obscure header file that you don't directly include. Grab the WinAPI SDK and DDK if you are using some flavor of MSVS, that should really go without saying. If you want to stick to a more opensource type of compiler then I cannot recommend MingW64 enough: http://sourceforge.net/projects/mingw-w64/
It takes minutes to setup a compiler profile for Code::Blocks and it has more headers and libraries then the original MingW.
Topic archived. No new replies allowed.