tags:

views:

108

answers:

3

I have experience in a variety of languages (Java, Perl, C#, PHP, javascript, ansi-C for microprocessors, Objective-C and others), with Win32 programming not being an area I've done a lot of work in. Now part of my job entails maintaining a large Win32 codebase that stretches back 15 years and includes everything from C written originally for Win95 to MFC to COM to 64-bit code for Win7 to C++ using Boost and so on. If there's a variation on how to do something it's in there.

Are there any good Win32 C/C++ references that discuss both the proper way to do things today and give you a little sense of how things evolved? Something like this discussion of all the various boolean types, or how to approach the API monstrosity of simply copying a string.

I don't see my career heading too far down this path, but I do like to understand what I'm working with and I think this is an important part of programming history.

thanks, Eric

A: 

Have a look at theForger's Win32 API tutorial. It might help you. Also the functionx win32 tutorial. I have to say, after a bit of Win32 I gave up and started using Qt.

Skilldrick
+2  A: 

As far as I know, Charles Petzold's Programming Windows is still the standard book on Win32 programming. It's old, but the basic underlying Win32 API hasn't changed. (New APIs have been added, like Vista's new synchronization primitives or new features in comctl32, but the basics are the same.)

Books for learning COM are discussed here.

Regarding the "proper way to do things today," it may not be hugely different, since many of the APIs are the same, although a modern C++ app might be more likely to use Qt or WTL (or, of course, .NET) rather than MFC. Modern C++ (using RAII, Boost, and templates) looks radically different than C or C++ of 15 years ago, but that's a whole different discussion.

Regarding "how things evolved," I suspect that's too broad of a question to easily answer. The Old New Thing (blog and book) is a good resource. Maybe check back issues of MSDN around the release of each new version of Windows to find articles on what's changed?

Specific changes of interest might be ANSI versus Unicode handling and Microsoft's new more-secure C runtime functions.

Regarding the "API monstrosity" that you link to: Yes, that looks bad, but it has a good explanation: there are versions for ANSI (narrow character), Unicode (UTF-16 / wchar_t), and multi-byte character set (MBCS, largely obsolete with Unicode) character encodings, plus C++ versions that can automatically deduce the length of the destination so that they don't do a buffer overflow.

Josh Kelley
Thanks everyone for the answers - this is useful stuff. It's actually kinda fun, in a "what doesn't kill you is good for you" kind of way.
EricM
+1  A: 

Jeffrey Richter Windows via C/C++ is the best book about WinAPI ever published (unlike Petzold's book this book published in 2007 not in 1998). Another good book about windows internals is Windows Internals by Mark E. Russinovich and David A. Solomon.

Essential COM by Don Box is the best book about COM ever published. And ATL Internals is the best book about ATL.

I thinks that all of this books could help you to understand this topics.

Sergey Teplyakov
Marked this as the answer not so much because the other ideas aren't good also, but I did get a copy of Richter's book and agree that it's excellent.
EricM