views:

345

answers:

3

Which is the best book for win32 api for beginners? Many in other posts suggested Charles Petzold's Programming Windows, but isn't that book old. As far as I remember it was written in Win9X, more then a decade ago on a dos based system. Windows has changed a lot since then. Is that book still good?

I've also considered QT, but I believe using QT I wont be able to get deep into OS roots. Am I right?

One more thing. It is called win32 api, so is api for win64 different then win32 or using win32 api would I be able to write applications for win64?

+1  A: 

Petzolds book still holds true. That's why they call it the Bible of Windows API Programming afterall.

There is a slightly newer "edition" so to speak, which is called Programming Microsoft Windows with C#, also by Petzold, and finally Windows® Internals: Including Windows Server 2008 and Windows Vista, Fifth Edition, which may provide you with some additional insight into the newer operating systems.

Kyle Rozendo
Ya I saw that book (Programming Microsoft Windows with C#), but I dont wanna go any way near C# or any other language other then C++.
Nik
That's quite short sighted? There are numerous benefits for learning more than one language.
Kyle Rozendo
+2  A: 

Win32 is old, as old as Petzold's book. Nothing fundamentally changed. Yes, you'll ultimately want to use a class library, raw Win32 is not productive. But starting with Qt doesn't help you discover what makes it tick. A couple of months with Petzold and C will.

The API for 64-bit isn't different, many programs port without much of any trouble with a simple re-compile.

Hans Passant
You said raw Win32 is not productive. Does it take for ever to write a fairly complex application? I've herd many horner stories abt MFC (not saying API is any better), WTL is not supported by Microsoft and QT is commercial.
Nik
@Nik: that's an entirely different question, maybe you ought to ask it in another thread. But yes, explicit Win32 takes a lot of code and is troublesome to get right. MFC is a thin wrapper, designed for programmers that already know Win32. Qt is thick, easier to use as long as you want to do what it lets you do.
Hans Passant
+1  A: 

I recommend these books:

  • Programming Applications for Windows by Jeffrey Richter, published by Microsoft Press.
  • Debugging Windows Applications by John Robbins, published by Microsoft press.

Earlier versions of both books covered Win32 and more recently I think they also cover using .Net.

Petzold's book will also be OK. Do not worry about the difference between Win32 and Win64, its largely a red herring. The API changed in a very few places between Win32 and Win64 IF you used the correct types specified by the API and do not do silly things like casting HANDLEs to DWORDs so that you can store them in a CUIntArray.

Always use containers of the correct type or use templated containers so you can get the correct type. For example: CTypedPtrArray to store handles.

I ported a 2 million line C++ app from Win32 to Win64 in 2000 (I had an early Itanium machine (sounded like a vaccuum cleaner, noisy slow thing) running 64 bit Whistler and a very early version of what became Visual Studio 7.0). The one major change was that changing the WndProc was not compatible (you have to use a different flag). For just about everything else, the bugs were people had been lazy and put HANDLEs or pointers into DWORD sized hashtables (CMAP) or CUIntArray. Changing the containers to the correct types pretty much fixed the problems. The whole program was ported using just one person, we didn't need a team to do it.

Stephen Kellett