Mastering the Win32 API with C23 and the Latest Windows SDK
Introduction: Why Native Windows Still Matters
- The Enduring Power of Native Code
- What Is “Modern” Win32 Development
- How This Book Is Organized
- A Minimal Working Program Before You Begin
Chapter 1: Setting Up Your Development Environment
- Installing Visual Studio and Workloads
- Understanding the Windows SDK Structure
- Configuring MSVC with C23 Support
- Building with CMake for Modern Projects
- Debugging Tools: WinDbg, Visual Studio Debugger and Beyond
- Project Layout and Build Configuration Best Practices
- Chapter Summary
Chapter 2: Windows Architecture and the Application Lifecycle
- Kernel Mode versus User Mode
- Processes, Threads and Address Spaces
- The Windows Memory Model
- How an Application Starts: Entry Points and Subsystems
- The Win32 Subsystem and DLL Loading
- Shutdown, Events and Graceful Termination
- Chapter Summary
Chapter 3: Unicode, Strings and Text Encoding
- Why You Cannot Escape Unicode on Modern Windows
- UTF-16: The Native Encoding of Windows
- UTF-8 Support in the Modern Windows SDK
- String APIs: Wide Character Functions and CRT Alternatives
- Converting Between Encodings Safely
- Localized Resources and Language-Specific Text
- Chapter Summary
Chapter 4: The Message Loop, Window Classes and Creating Windows
- How Windows Event Handling Works
- Designing Your Message Loop
- Registering a Window Class
- Creating Top-Level Windows with CreateWindowEx
- The Window Procedure: Handling Messages Systematically
- Common Pitfalls in Message Routing
- Chapter Summary
Chapter 5: Drawing with GDI, GDI+ and Direct2D
- The GDI Legacy: When It Still Makes Sense
- GDI+ for Simple Graphics and Image Handling
- Direct2D: Modern Hardware-Accelerated Rendering
- DirectWrite for Professional Text Rendering
- Choosing the Right Rendering API for Your Application
- High-DPI Aware Drawing and Per-Monitor Scaling
- Chapter Summary
Chapter 6: Controls, Dialogs, Menus and Resources
- Common Controls Initialization and Usage
- Building Dialog Boxes from Templates
- Menus, Toolbar Integration and Context Menus
- Resource Scripts: Icons, Cursors, Bitmaps and Strings
- Accelerators and Keyboard Navigation
- Custom Controls and Owner-Draw Techniques
- Chapter Summary
Chapter 7: File I/O, Registry Access and Asynchronous Operations
- The Win32 File API: CreateFile, ReadFile, WriteFile
- Directory Operations and Path Handling
- Overlapped I/O for Asynchronous File Access
- Registry APIs for Application Configuration
- Modern Async Patterns: IOCP and Completion Routines
- Secure File Handling and ACL Basics
- Chapter Summary
Chapter 8: Processes, Threads, Synchronization and Parallelism
- Creating and Managing Processes
- Thread Creation and Lifecycle Management
- Synchronization Primitives: Mutexes, Critical Sections, Events
- Condition Variables and Modern Threading with C++23
- Thread Pools and Work Stealing
- Keeping the UI Responsive Under Load
- Chapter Summary
Chapter 9: Networking with WinSock and Modern Alternatives
- WinSock Initialization and Socket Basics
- TCP Client and Server Patterns
- UDP Communication and Broadcast
- Secure Sockets with Schannel
- Async Networking with Completion Ports
- Modern HTTP Clients for Windows Desktop
- Chapter Summary
Chapter 10: COM Fundamentals and Windows Runtime Integration
- What Is COM and Why It Still Matters
- The COM Object Model: Interfaces and Reference Counting
- Initializing COM and Creating Objects
- HRESULT Error Handling Patterns
- Using COM for Shell Integration and System Services
- Connecting Native Code with Windows Runtime APIs
- Chapter Summary
Chapter 11: Memory Management, Error Handling and Security
- Heap Allocation and Memory Pool Strategies
- Structured Exception Handling versus SEH Alternatives
- The HRESULT Convention and Error Propagation
- Secure Coding: Buffer Overflows, Injection and Mitigation
- Token Manipulation and Privilege Escalation Prevention
- Debugging Memory Leaks with Visual Studio and WinDbg
- Chapter Summary
Chapter 12: Services, Shell Integration and System Programming
- Writing Windows Services
- Shell Extensions and Context Menu Integration
- System Tray Icons and Notification Areas
- Task Scheduler Registration and Execution
- Event Logging for Production Applications
- Interprocess Communication: Pipes, Named Events and Shared Memory
- Chapter Summary
Chapter 13: Accessibility, Internationalization and Modern UX Standards
- Making Your Application Accessible with UI Automation
- Keyboard Navigation and Focus Management
- High-DPI Awareness: Per-Monitor V2 Best Practices
- Dark Mode Support and Theming
- Internationalization Beyond String Resources
- Following the Fluent Design System Guidelines
- Chapter Summary
Chapter 14: Debugging, Profiling, Testing and Deployment
- Advanced Debugging with Visual Studio and WinDbg
- Performance Profiling: CPU, Memory and GPU
- Crash Dump Analysis and Post-Mortem Debugging
- Unit Testing Native Windows Code
- Packaging with MSI, AppX and ClickOnce Alternatives
- Side-by-Side Assemblies and Runtime Dependencies
- Chapter Summary
Conclusion: The Future of Native Windows Development
- What You Now Know and Can Build
- Where Native Development Is Headed
- Continuing Your Journey as a Windows Developer
- Final Thoughts on Craft and Longevity