Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.
This is a working draft of a pre-release book. It is available before the published date as part of the Rough Cuts service.
“If you’re writing a native Win32 program or just want to know what the OS is really doing underneath, you need John’s book. He covers the stuff that real systems programmers absolutely must know. Recommended.”
–Chris Sells, Microsoft Corporation
“This fourth edition does a great job of incorporating new features in the Vista, Windows 2008, and Windows 7 API, but also stays true to teaching the foundational elements of building applications that target the Windows OS.”
–Jason Beres, Product Management, Infragistics
The Definitive Guide to Windows API Programming, Fully Updated for Windows 7, Windows Server 2008, and Windows Vista
Windows System Programming, Fourth Edition, now contains extensive new coverage of 64-bit programming, parallelism, multicore systems, and many other crucial topics. Johnson Hart’s robust code examples have been updated and streamlined throughout. They have been debugged and tested in both 32-bit and 64-bit versions, on single and multiprocessor systems, and under Windows 7, Vista, Server 2008, and Windows XP. To clarify program operation, sample programs are now illustrated with dozens of screenshots.
Hart systematically covers Windows externals at the API level, presenting practical coverage of all the services Windows programmers need, and emphasizing how Windows functions actually behave and interact in real-world applications. Hart begins with features used in single-process applications and gradually progresses to more sophisticated functions and multithreaded environments. Topics covered include file systems, memory management, exceptions, processes, threads, synchronization, interprocess communication, Windows services, and security.
New coverage in this edition includes
A companion Web site, jmhartsoftware.com, contains all sample code, Visual Studio projects, additional examples, errata, reader comments, and Windows commentary and discussion.
Figures xvii
Tables xix
Programs xxi
Program Runs xxv
Preface xxvii
About the Author xxxvii
Chapter 1: Getting Started with Windows 1
Operating System Essentials 1
Windows Evolution 2
Windows Versions 3
The Windows Market Role 5
Windows, Standards, and Open Systems 6
Windows Principles 7
32-bit and 64-bit Source Code Portability 10
The Standard C Library: When to Use It for File Processing 10
What You Need to Use This Book 11
Example: A Simple Sequential File Copy 13
Summary 20
Exercises 22
Chapter 2: Using the Windows File System and Character I/O 25
The Windows File Systems 26
File Naming 27
Opening, Reading, Writing, and Closing Files 28
Interlude: Unicode and Generic Characters 34
Unicode Strategies 37
Example: Error Processing 38
Standard Devices 39
Example: Copying Multiple Files to Standard Output 41
Example: Simple File Encryption 43
File and Directory Management 46
Console I/O 51
Example: Printing and Prompting 53
Example: Printing the Current Directory 55
Summary 56
Exercises 57
Chapter 3: Advanced File and Directory Processing, and the Registry 59
The 64-Bit File System 59
File Pointers 60
Getting the File Size 64
Example: Random Record Updates 65
File Attributes and Directory Processing 70
Example: Listing File Attributes 75
Example: Setting File Times 78
File Processing Strategies 80
File Locking 81
The Registry 86
Registry Management 88
Example: Listing Registry Keys and Contents 92
Summary 96
Exercises 97
Chapter 4: Exception Handling 101
Exceptions and Their Handlers 101
Floating-Point Exceptions 108
Errors and Exceptions 110
Example: Treating Errors as Exceptions 112
Termination Handlers 113
Example: Using Termination Handlers to Improve Program Quality 117
Example: Using a Filter Function 120
Console Control Handlers 124
Example: A Console Control Handler 126
Vectored Exception Handling 128
Summary 129
Exerci