did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780130225573

Win32 System Services The Heart of Windows 98 and Windows 2000

by ;
  • ISBN13:

    9780130225573

  • ISBN10:

    0130225576

  • Edition: 3rd
  • Format: Paperback
  • Copyright: 2000-12-01
  • Publisher: Prentice Hall
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $49.99

Summary

Preface

The Win32 system services are the innovative, cutting-edge capabilities that make Windows 2000 and Windows 98 interesting and exciting. Amid all of the media attention surrounding Windows 2000 and 98, you have probably heard and read about many of the modern capabilities that these operating systems contain:

  • Processes and threads
  • Synchronization
  • Remote Procedure Calls (RPCs) and DCOM (Distributed COM)
  • Event logging
  • Network communications
  • TCP/IP network communications
  • File mapping and Active Directory
  • Interprocess and Interprocessor communication
  • Compressed file access
  • Network drive- and printer-sharing
  • Serial communications
  • Services (background processing like UNIX daemons)
  • Object and file security

The goal of this book is to show you how to use all of these different services in your own applications. This book contains hundreds of concise, clear, and easy-to-understand example programs and explanations. The examples show you how to access the system services listed above, as well as many others. You can use these examples directly, to understand the concepts. You can also drop the sample code into your own programs and then extend it to give your applications new and useful features.

By learning about the many and varied system services available inside of Windows 2000 and 98, you can make your programs much more interesting to the user. For example, if you learn about threads and then add multiple threads to your applications, the user gets a much smoother interface (see Chapter 6). Your program will also take advantage of multiple processors on machines that have them. If you add network support to your applications, the user is able to access network resources that are unavailable on a single machine (see Chapter 8). If you add modem support, you can use it to let the user dial into a remote system (see Chapter 11). Or you might use a modem to let the user dial a support line or registration system for a product that your company sells.

The goal of this book is to give you a thorough and clear understanding of the system services so that you can take advantage of all of the capabilities that Windows has to offer.

Audience

This book is designed for two types of people. If you are a devoted connoisseur or student of programming, the study of the system functions is interesting in its own right. It's fun to see what functions are available, and to try to think of ways to exploit those capabilities. One way to use this book is to simply browse through it and see what is possible. You can work with the examples and extend them in ways that you find enjoyable.

If, on the other hand, you are a programmer with a deadline, enjoyable entertainment is probably not your goal. You may have looked at the huge number of functions in the Windows API and found it discouraging. Where do you start? What you need is a set of useful examples and clear explanations that quickly solve your specific problems. You will find this book useful because it organizes concepts logically and provides the material that you need to master a specific topic very quickly.

If you are migrating from another operating system to Windows, this book will help you to quickly map your existing knowledge into the Windows framework. See Chapter 1 for a list of the 121 most common programming questions in Windows, as well as for the locations of the sections that contain the answers.

Organization

This book is organized by functional categories. For example, Chapter 2 talks about all of the functions that pertain to file input/output and file handling. Chapter 3 deals with disk drives. Chapter 4 discusses directories. Chapter 5 talks about the next-generation directory services, known as Active Directory in Windows 2000. Chapter 6 talks about processes and threads. You will find that each chapter starts with a general overview of the topic, followed by sections that describe and give examples for subsets of functions.

In many chapters you will find integrating examples that combine different capabilities from several chapters to create larger applications. Many of these larger examples form complete applications that you can use as starting points for new projects of your own.

Philosophy

Several principles guide the content of this book. The first principle is the most important and is therefore used throughout: it is simplicity. There is nothing worse than looking up a function, only to find that its example is embedded within sample code that takes three days to comprehend because it is 28 pages long. In all cases a function is first demonstrated in code that is as simple as possible so that you can extract the essence of each one very quickly. They may then be integrated into larger examples. In many cases you will look at the example code and say to yourself, "This is easy!" That is exactly the intent. If the book makes everything look simple and easy for you, then it has accomplished its goal.

The second principle driving this book is the idea of functional families. Functions in the 32-bit API very rarely exist on their own-it is far more common to find small collections of functions that relate very closely to one another. For example, the ReadFile function reads from a file, but you must open the file with CreateFile before you can read from it and then remember to close it with CloseHandle afterwards (see Chapter 2). These functions belong to a family. In this book you will generally find small groupings of functions described as logical units.

The third principle in this book is that of currency. The Windows API has been around for some time, and when you look at it you will find that there is a certain amount of layering. The documentation will often say things like, "this function is retained for compatibility with version 1.8, but has been superseded by function xyz." This book deals only with the current functions, and leaves the superseded ones to die in peace.

The last principle guiding this book is independence. Each chapter in this book is as stand-alone as possible, so that you can jump around in the book as you please. In cases where material from other chapters is important, you will find references to the related sections.

Prerequisites and Languages

This book makes no assumptions about your former knowledge of systems programming in Windows or in any other system. Its only real assumption is that you know C and/or C++. You will find that the example code can be divided into two categories:

  1. Text examples that run in "console mode." These programs run from the MS-DOS prompt, accept keyboard input, and produce text output. They form the vast majority of the code in this book because they are simple. These programs are C++- compatible, but the only elements really being used from C++ are the I/O stream libraries.
  2. "Windows" programs that use the Windows GUI. These programs use C++ and the Microsoft Foundation Class library (MFC). The book Visual C++: Developing Professional Applications for Windows 98 and NT using MFC, by Marshall Brain and Lance Lovette (ISBN 0-13-085121-3), describes how to create programs with MFC, and will be useful as a tool to help you understand these examples if you are not already familiar with MFC. You can develop C-language Windows programs using only the Win32 API. However, the Visual C++ tools make low-level Win32 programming easier. But to take advantage of the Visual C++ and MFC tools, you should have a good grasp of the underlying Win32 API.

If you are a C programmer with no C++ experience, you will have no trouble understanding the console programs. The only unusual thing you

Author Biography

MARSHALL BRAIN is founder and principal of Interface Technologies, Research Triangle Park, NC. His firm specializes in software training for developers at leading financial companies. His recent Prentice Hall PTR books include Developing Professional Applications for Windows 98 and NT Using MFC and Windows CE 3.0: Application Programming (with Nick Gratten).

RON REEVES is President of Computer Engineering, Inc., a leading consulting and training company based in Howell, MI.

Table of Contents

Preface xiii
Introduction
1(20)
One Hundred and Twenty-one Questions About Windows 2000 and 98
1(7)
Compiling Code
8(1)
Terminology
9(1)
Error Handling
10(2)
Handles and Objects
12(3)
Using the Microsoft Documentation
15(1)
Bugs in the 32-Bit API
16(2)
Differences Between Windows 98 and Windows 2000
18(3)
Files
21(44)
The Possibilities
22(1)
Overview
22(2)
Opening and Reading from a File
24(4)
Getting and Setting File Information
28(8)
File Operations
36(3)
Temporary Files
39(2)
File Reading and Writing
41(5)
Asynchronous File Operations
46(1)
File Locking
47(6)
Compressed Files
53(6)
File Mapping
59(5)
Conclusion
64(1)
Drives
65(23)
The Possibilities
67(1)
Getting Volume Information
67(2)
Getting Drive Types
69(2)
Getting Free Space
71(1)
Getting Logical Drives and Drive Strings
72(2)
Setting the Volume Label
74(1)
WNet Functions
75(12)
Conclusion
87(1)
Directories
88(18)
The Possibilities
89(1)
Creating and Deleting Directories
89(2)
Getting and Setting the Current Directory
91(2)
Searching for a File
93(2)
Traversing Directory Trees
95(6)
Combining Capabilities
101(3)
Detecting Changes to Directories and Files
104(1)
Conclusion
105(1)
Active Directory
106(10)
The Possibilities
106(1)
Introduction to Active Directory
107(3)
Active Directory Architecture
110(1)
Frequently Asked Questions
111(3)
Conclusion
114(2)
Process and Threads
116(50)
The Possibilities
116(1)
Introduction
117(3)
Simple Examples
120(10)
Using Threads in GUI Applications
130(9)
Matching the Number of Threads to the Number of CPU's
139(8)
Using Thread Local Storage
147(4)
Thread Priorities
151(4)
Other Thread Functions
155(2)
Processes
157(3)
Inheriting Handles
160(3)
Interprocess Communication
163(1)
Jobs
164(1)
Conclusion
165(1)
Synchronization
166(58)
Understanding the Problem
166(5)
Four Different Synchronization Methods
171(22)
Deadlocks, Starvation, and Other Synchronization Bugs
193(11)
Wait Functions
204(2)
Overlapped I/O
206(10)
Change Functions
216(3)
Integrating Synchronization into MFC Programs
219(4)
Conclusion
223(1)
Network Communications
224(69)
The Possibilities
224(2)
Understanding Your Options
226(4)
Mailslots
230(13)
Named Pipes
243(8)
Named Pipe Client/Server Systems
251(14)
Connection with UNIX and Other TCP/IP Machines
265(4)
UDP Connections
269(10)
TCP Connections
279(13)
Conclusion
292(1)
Remote Procedure Calls
293(66)
The Possibilities
293(2)
The Basic Idea
295(1)
Design Issues
296(2)
Creating RPCs
298(7)
Understanding RPCs at a High Level
305(3)
Parameter Passing
308(3)
Understanding the Code
311(4)
Setting up a Name Server in the Registry
315(1)
Manual Binding with Implicit Handles
316(11)
An RPC Server for Mandelbrot Sets
327(10)
Improving the Mandelbrot RPC Server
337(8)
Explicit Handles
345(4)
Context Handles
349(7)
Common Questions
356(2)
Conclusion
358(1)
Distribute COM (DCOM)
359(9)
DCOM Architecture
360(1)
Components and Reuse
361(1)
Location Independence
362(1)
Connection Management
363(1)
Scalability
364(3)
Conclusion
367(1)
Communications
368(29)
The Possibilities
368(1)
Understanding Serial Communications
369(2)
A Simple Communications Application
371(8)
Getting Communications Events
379(2)
A Simple Bulletin Board System
381(4)
Flow Control
385(2)
A Simple TTY Terminal Program
387(7)
Other Communications Functions
394(2)
Conclusion
396(1)
Windows 2000 Services
397(56)
The Possibilities
398(1)
Understanding Services
399(1)
Service Choreography
400(2)
The Simplest Service
402(13)
Installing and Removing a Service
415(7)
Displaying Dialogs from within a Service
422(4)
Multiple Services in an Executable
426(5)
Getting and Setting Configuration Information
431(6)
Controlling Services
437(2)
Enumerating Services
439(3)
Placing an RPC Server in a Server
442(10)
Conclusion
452(1)
Security
453(78)
The Possibilities
453(3)
Understanding the Terminology and Concepts of the Windows 2000 Security System
456(2)
Windows 2000 Security Vocabulary
458(5)
Simple Examples
463(9)
Securable Objects and Access Rights
472(9)
Examining Existing Access Tokens and Security Descriptors
481(20)
Privileges
501(7)
Adding and Deleting ACEs
508(17)
Impersonation
525(5)
Conclusion
530(1)
Consoles
531(31)
The Possibilities
531(1)
Raw versus Cooked Input
532(1)
Simple Examples
533(6)
Raw Input
539(10)
Other Input Events
549(6)
Other Capabilities
555(6)
Conclusion
561(1)
Microsoft Management Console (MMC)
562(8)
The Possibilities
563(1)
MMC Interfaces and Methods
563(6)
ATL Snap-In Wizard
569(1)
Conclusion
569(1)
System Information
570(15)
The GetSystemInfo Function
570(2)
Other System Information Functions
572(6)
Getting and Setting Environment Strings
578(2)
Shutting Down the System
580(5)
Dynamic Link Libraries
585(21)
The Possibilities
585(1)
Overview
586(2)
Creating a Simple DLL
588(3)
Understanding a Simple DLL
591(2)
Load-time versus Run-time Linking
593(5)
DLL Entry Points
598(3)
Memory Models
601(4)
Conclusion
605(1)
Component Object Model (COM)
606(6)
COM Fundamentals
607(2)
Component Object Library
609(1)
Summary
610(2)
COM+
612(8)
COM+ Programming Overview
612(2)
COM+ Application Overview
614(2)
Developing COM+ Applications
616(1)
COM+ Design Assumptions and Principles
617(2)
Conclusion
619(1)
Windows Distributed Network Architecture (DNA)
620(17)
Frequently Asked Questions about Windows DNA
621(6)
Microsoft Windows Distributed Internet Application Architecture
627(1)
The Presentation Tier
627(4)
Business Services Tier
631(3)
Data Services Tier
634(2)
Conclusion
636(1)
Miscellaneous
637(49)
Registry
637(12)
The Event Log
649(10)
Time
659(8)
Memory
667(6)
Structured Exception Handling
673(9)
Error Handling
682(4)
Appendix A Compling the Code in This Book 686(6)
Appendix B Contacting the Authors 692(1)
Appendix C Error Codes 693(2)
Index 695

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Excerpts

PrefaceThe Win32 system services are the innovative, cutting-edge capabilities that make Windows 2000 and Windows 98 interesting and exciting. Amid all of the media attention surrounding Windows 2000 and 98, you have probably heard and read about many of the modern capabilities that these operating systems contain: Processes and threads Synchronization Remote Procedure Calls (RPCs) and DCOM (Distributed COM) Event logging Network communications TCP/IP network communications File mapping and Active Directory Interprocess and Interprocessor communication Compressed file access Network drive- and printer-sharing Serial communications Services (background processing like UNIX daemons) Object and file securityThe goal of this book is to show you how to use all of these different services in your own applications. This book contains hundreds of concise, clear, and easy-to-understand example programs and explanations. The examples show you how to access the system services listed above, as well as many others. You can use these examples directly, to understand the concepts. You can also drop the sample code into your own programs and then extend it to give your applications new and useful features.By learning about the many and varied system services available inside of Windows 2000 and 98, you can make your programs much more interesting to the user. For example, if you learn about threads and then add multiple threads to your applications, the user gets a much smoother interface (see Chapter 6). Your program will also take advantage of multiple processors on machines that have them. If you add network support to your applications, the user is able to access network resources that are unavailable on a single machine (see Chapter 8). If you add modem support, you can use it to let the user dial into a remote system (see Chapter 11). Or you might use a modem to let the user dial a support line or registration system for a product that your company sells.The goal of this book is to give you a thorough and clear understanding of the system services so that you can take advantage of all of the capabilities that Windows has to offer. AudienceThis book is designed for two types of people. If you are a devoted connoisseur or student of programming, the study of the system functions is interesting in its own right. It's fun to see what functions are available, and to try to think of ways to exploit those capabilities. One way to use this book is to simply browse through it and see what is possible. You can work with the examples and extend them in ways that you find enjoyable.If, on the other hand, you are a programmer with a deadline, enjoyable entertainment is probably not your goal. You may have looked at the huge number of functions in the Windows API and found it discouraging. Where do you start? What you need is a set of useful examples and clear explanations that quickly solve your specific problems. You will find this book useful because it organizes concepts logically and provides the material that you need to master a specific topic very quickly.If you are migrating from another operating system to Windows, this book will help you to quickly map your existing knowledge into the Windows framework. See Chapter 1 for a list of the 121 most common programming questions in Windows, as well as for the locations of the sections that contain the answers. OrganizationThis book is organized by functional categories. For example, Chapter 2 talks about all of the functions that pertain to file input/output and file handling. Chapter 3 deals with disk drives. Chapter 4 discusses directories. Chapter 5 talks about the next-generation directory services, known as Active Directory in Windows 2000. Chapter 6 talks about processes and threads. You will fin

Rewards Program