r/AskProgramming • u/Technical_Introvert0 • May 04 '26
C/C++ Where can I find complete C++ resources for Windows.h library and the WIN32 API?
So I have been trying to learn the windows API in C/C++.. so far I only know shellexecute thanks to RAD Studio.. and sleep ().. But I wanna understand the rest of the whole WIN32 API.. where can I find the resources? I checked the microsoft site and they have some of them not all. I am essentially looking for a course..or book to check out
2
Upvotes
13
u/untold8 May 04 '26
Petzold's "Programming Windows" (5th edition for the C/Win32 path, the 6th went C# only) is still the canonical book. Long, but it walks you through window procedures, message loops, GDI etc. in the right order, which is exactly the part the docs don't.
Once you're past shellexecute and CreateWindow, Raymond Chen's blog The Old New Thing is gold. He was on the windows team for 30 years and the posts explain why the API is shaped the way it is.
The MS docs at learn.microsoft.com/en-us/windows/win32/ really do cover everything, but the index is brutal. If you read Petzold first you'll actually know what to search for.
4
u/rickpo May 04 '26
I'm pretty sure the entire Win32 API is documented on the Microsoft site. What particularly are you missing?
Build desktop Windows apps using the Win32 API - Win32 apps | Microsoft Learn
The getting started and tutorial sections will get you up and running.
4
u/rlebeau47 May 04 '26
Microsoft
The Win32 API is MASSIVE. Nobody really understands the WHOLE thing. Nor should you be trying to. Focus only on the particular pieces you need to use. Window management (which RAD Studio already handles for you), file I/O, threads and synchronization, communications, Shell interactions, etc. If you keep your focus narrow, it's easier to find what you're looking for on Microsoft's site.
1
u/mredding May 05 '26
Pick one. These are decidedly different languages with very different consequences. C++ is not entirely compatible with C as these languages both diverged 45 years ago.
In the beginning, there was the Win32 C API. Then there was MFC. Then ATL. Then WTL. Then WRL. Today, there is C++/WinRT. This is the modern C++17 API. The Universal Windows Platform (UWP) is built upon it, and you are expected to use THAT.
If you are going to code in C, you're stuck with the Win32 API. You can load dynamic libraries with a foreign function interface (
dlopen) and then map those library methods to handles yourself, but I can't speak to the object model. TYPICALLY - if Microsoft STAYED smart, they will have implemented ALL their user runtime libraries in terms of the system API - which is essentially C. I just can't guarantee that because I haven't written platform specific Windows GUI code in 25 years.If you're going to code in C++, use UWP.
As to where to find sources - I would start with the MSDN, Microsoft's information database. It used to be the gold standard - again, 25 years ago, but now I don't know.
If you want straight Win32 API, I recommend you find an old Microsoft Press publication on the subject - these were tomes, thicker and heavier than old phone books, but the Win32 API will not have changed. There may be additions, but only the MSDN could tell you that, if the information is still maintained. And this would just be to start. The book doesn't tell you everything - you have to dig through the headers for more. And that doesn't tell you anything about how the API has advanced, you'd have to investigate/reverse engineer the user libraries for that.
The Win32 API maintains backward compatibility by providing fixed interfaces and versioned structures.
RegisterClassExis one such example - it can accept several different structures through it's parameter list, not justWNDCLASSEX. The version is determined usually by a combination of the first couple fields - always a size, and often a flag field. They use overlapping types to read the header, and then cast to the type they've deduced - and it better be correct.Everything else is opaque pointers passed over the API boundary as handles to kernel and library resources. A handle to a window is just a void pointer. To what? Well - the contents might not actually be a pointer at all, but an offset into some internal structure you're not privileged to. That's why it's a handle, so when you say do a thing and act on a resource you have the handle to express WHICH resource specifically, if it can't otherwise be deduced.
How have these interfaces evolved in the last 25-30 years? From a C API perspective - no clue. You'd have to deduce that yourself, how to express the more modern language interfaces in terms of C API, if it's possible.
1
u/Living_Fig_6386 May 05 '26
Windows.h is a C header file, not a library. It was the primary header for the Win32 API on Microsoft Windows. I'd suggest you get a good book on the Windows SDK, like the one from Petzold. The Windows SDK is huge and can be complicated. There's online documentation, but it presumes that you are intimately familiar with many of the peculiarities of Windows' internals and the macros they use.
1
u/Cdream-2018 May 11 '26
Ii thoroughly enjoy coding in vb.net tbh