More Ebooks:

MCSE Training Kit - Microsoft Windows 2000 Professional

MCSE Training Kit - Microsoft Windows 2000 Network Infrastructure Administration

MCSE Training Kit - Microsoft Windows 2000 Active Directory Services

MCSE Training Guide Windows NT Server 4

MAPI, SAPI, and TAPI Developer`s Guide

Management of International Networks Cost-Effective Strategies for the New Telecom Regulations and Services

Learn Pascal in a Three Days (2nd Ed.)

Java Unleashed, Second Edition

10 Minute Guide to Schedule+ for Windows 95

Concurrent Routing and Bridging and Advanced Bridging Options - CBT System

find on eBook ToC:

.NET Framework Solutions: In Search of the Lost Win32 API

.NET Framework Solutions: In Search of the Lost Win32 API

John Paul Mueller, Sybex

ISBN:078214134X, Edition: , 2002-09-24

Price: $59.99

Table of Contents

Introduction ~ 1
Overview ~ 1
Hunting for Treasure ~ 1
Hidden Nuggets ~ 1
Who Should Read This Book? ~ 2
Tools Required ~ 2
Conventions Used in This Book ~ 2
Icons ~ 3

Part I: An Overview of the Win32 API ~ 5

Chapter 1: Overcoming Holes in the .NET Framework ~ 6
Overview ~ 6
Why Access the Win32 API? ~ 6
A Case of Missing Functionality ~ 7
Win32 Function Types ~ 8
Win32 Access Requirements ~ 11
Win32 Access for C# Developers ~ 14
Understanding the Effects of Unsafe Code ~ 14
Understanding the Effects of Pointers ~ 15
Advantages for the C# Developer ~ 16
Win32 Access for Visual Basic Developers ~ 16
Understanding Visual Basic Limitations ~ 17
Advantages for the Visual Basic Developer ~ 18
Where Do You Go from Here? ~ 18

Chapter 2: Working with Win32 API Data ~ 19
Overview ~ 19
A Short View of Data ~ 19
Working with Variables ~ 24
Converting Variables to C# Types ~ 25
Converting Variables to Visual Basic Types ~ 25
Special Rules for COM ~ 26
Working with Data Structures ~ 28
Working with Pointers ~ 32
Working with Enumerations ~ 32
Importing Resources ~ 33
Understanding .NET Framework Functionality ~ 33
Using the IDE Features ~ 34
Working with the Win32 API ~ 35
Where Do You Go from Here? ~ 36

Chapter 3: Accessing the Win32 API ~ 37
Overview ~ 37
An Overview of the DLLs ~ 37
Types of Win32 Access ~ 38
Direct DLL Access ~ 39
C LIB Access ~ 40
A Direct DLL Access Example ~ 42
A C LIB Wrappers Access Example ~ 43
A C LIB Substitute Functions Example ~ 49
Interpreting Error and Result Values ~ 51
Helpful Win32 Programming Tools ~ 52
Dependency Walker ~ 53
Error Lookup ~ 59
Spy++ ~ 60
Where Do You Go from Here? ~ 64

Chapter 4: Processing Windows Messages ~ 65
Overview ~ 65
Understanding the Windows Message Types ~ 65
Windows Message Handlers Found in the .NET Framework ~ 68
An Overview of Windows Message Functions ~ 70
SendMessage() ~ 70
PostMessage(), PostThreadMessage, and PostQuitMessage() ~ 72
SendNotifyMessage() ~ 77
SendMessageCallback() ~ 78
GetMessage() and PeekMessage() ~ 78
RegisterWindowMessage() ~ 79
Creating a Windows Message Handler Example ~ 79
Creating the Event ~ 79
Creating the Windows Message Loop Override ~ 80
Creating the Event Handler ~ 81
Demonstrating the Windows Message Handler ~ 82
Developing for Thread Safety ~ 83
Where Do You Go from Here? ~ 84

Chapter 5: Using Callback Functions ~ 85
Overview ~ 85
What Is a Callback Function? ~ 85
Using Callback Functions ~ 86
An Overview of Callback Function Prototypes ~ 86
Implementing a Callback from the Managed Environment ~ 87
Implementing a Callback from a Wrapper DLL ~ 91
Enumerating Calendar Information Example ~ 95
Creating the Macro Wrapper DLL ~ 96
Creating the EnumCalendarInfoEx() Function Code ~ 98
Demonstrating the Calendar Enumeration ~ 99
Where Do You Go from Here? ~ 101

Part II: Fixing Holes in Standard Applications ~ 102

Chapter 6: Gaining Support for the Console Application ~ 103
Overview ~ 103
What Does the .NET Framework Provide? ~ 103
Clearing the Screen Example ~ 104
Getting Console Information Examples ~ 107
Working with Code Pages ~ 107
Gaining Access to Console Mode Information ~ 109
Working with Processes ~ 113
Changing the Environment Examples ~ 114
Accessing the Environmental Strings ~ 115
Using Cursors and Fonts ~ 118
Determining the Console Window Title ~ 122
Manipulating the Console Screen Buffer ~ 123
Where Do You Go from Here? ~ 126

Chapter 7: Accessing the Hardware Directly ~ 128
Overview ~ 128
When is Direct Access Required? ~ 128
Serial Port Access Examples ~ 130
Creating a Serial Stream ~ 130
Determining the Port Status ~ 136
Parallel Port Access Examples ~ 143
Creating the Wrapper DLL ~ 144
Viewing the First Level of Printer Information ~ 146
Viewing the Second Level of Printer Information ~ 148
Where Do You Go from Here? ~ 152

Chapter 8: Overcoming Security Issues ~ 154
Overview ~ 154
An Overview of Windows Security ~ 154
A Detailed View of the Windows Security API ~ 155
An Overview of the Functions ~ 161
Using the Access Control Editor ~ 165
Using the Security Configuration Editor ~ 167
Understanding How .NET Role-Based Security Differs ~ 169
Looking Up an Account SID Example ~ 172
Using the GetFileSecurity() Function Example ~ 175
Working with ACEs Example ~ 178
Where Do You Go from Here? ~ 183

Part III: Fixing Advanced Win32 API Problems ~ 185

Chapter 9: Accessing Windows XP Special Features ~ 186
Overview ~ 186
What's New in Windows XP? ~ 186
Common Features ~ 187
Professional Edition Exclusive Features ~ 188
Determining the Operating System Version Example ~ 189
Working with Theme Support Example ~ 195
Balloon Help Example ~ 202
Using NUnit for Automated Testing ~ 207
Where Do You Go from Here? ~ 210

Chapter 10: Using Operating System Special Functions ~ 211
Overview ~ 211
Accessing Status and Other Information ~ 211
Learning How to Avoid Version Compatibility Problems ~ 213
Determining System Power Status Example ~ 215
Creating an Application Shortcut Example ~ 219
Shutting the System Down Remotely Example ~ 222
Obtaining Device Capabilities Example ~ 225
File Compression ~ 227
Using PC-Lint for C++ Development ~ 228
Where Do You Go from Here? ~ 230

Chapter 11: Accessing the Media Player ~ 232
Overview ~ 232
A Quick Overview of the Media Player ~ 232
Windows Media Player General Operation ~ 233
Internet Content ~ 234
Using the Media Library ~ 235
Displaying a Configuration Dialog Example ~ 236
Playing Sound Files Example ~ 240
Determining Device Capabilities ~ 241
Opening a File ~ 244
Playing a File ~ 251
Pausing and Stopping a File ~ 253
Required Application Cleanup ~ 254
Using IconForge ~ 254
Where Do You Go from Here? ~ 257

Chapter 12: Working with Microsoft Management Console ~ 258
Overview ~ 258
Using GUIDGen ~ 258
The Case for an MMC Snap-In ~ 260
Creating a Wrapper DLL ~ 262
Creating an Interface ~ 263
Writing the MMC Wrapper DLL ~ 266
Developing the MMC Snap-In Example ~ 277
Developing an About Dialog ~ 277
Working with IDataObject ~ 279
Creating IComponent and IComponentData ~ 282
Testing the Snap-In within MMC ~ 284
Where Do You Go from Here? ~ 286

Part IV: Working with DirectX ~ 288

Chapter 13: Creating DirectX Structures and Data Elements ~ 289
Overview ~ 289
Using the DXDIAG Utility ~ 289
Learning about DirectX Compatibility ~ 290
Viewing the Drivers ~ 292
Working with the DirectX Structures ~ 294
An Overview of the Data Structures ~ 294
Structure Conversion Essentials ~ 297
Understanding DirectX Data Pitfalls in the Managed Environment ~ 303
Where Do You Go from Here? ~ 305

Chapter 14: Developing DirectX Access Routines ~ 307
Overview ~ 307
Working with DirectX Functions ~ 307
DirectDrawCreate() and DirectDrawCreateEx() ~ 308
DirectDrawCreateClipper() ~ 309
DirectDrawEnumerate() and DirectDrawEnumerateEx() ~ 310
Function Declarations ~ 310
Function Return Values ~ 312
Creating DirectX Callback Function Prototypes ~ 315
DDEnumCallback() and DDEnumCallbackEx() ~ 315
EnumModesCallback() and EnumModesCallback2() ~ 315
EnumSurfacesCallback(), EnumSurfacesCallback2(), and EnumSurfacesCallback7() ~ 316
EnumVideoCallback() ~ 316
Delegate Declarations ~ 316
Working with the DirectX Interfaces and Classes ~ 317
Learning the DirectX Capabilities of the Host Machine Example ~ 318
Using the DirectDrawEnumerateEx() Function ~ 318
Using the DirectX Caps Viewer Tool ~ 320
A Simple 2D DirectDraw Example ~ 324
Importing the DirectX COM Library ~ 324
Writing the Code ~ 325
Using the GIF Construction Set ~ 329
Using the GIF Construction Set ~ 333
Where Do You Go from Here? ~ 336

Chapter 15: Creating Applications with DirectX 8.1 ~ 337
Overview ~ 337
An Overview of DirectX 7 and DirectX 8.1 Differences ~ 337
Consolidated Objects ~ 337
Updated Objects and Features ~ 338
An Overview of the Tools ~ 340
Using the DirectX Control Panel Application ~ 340
Using the DMO Test Utility ~ 344
Creating a Test File Using GraphEdit ~ 344
Testing the WavesReverb DMO ~ 346
A Simple DirectSound Example ~ 348
Using the Force Feedback Editor ~ 350
A Simple DirectInput Example ~ 354
Using the DirectX Texture Tool ~ 357
Where Do You Go from Here? ~ 359

Chapter 16: Extended DirectX Programming Examples ~ 360
Overview ~ 360
Using the GraphEdit Utility ~ 360
Creating a Connection ~ 360
Working with Multiple Streams ~ 361
Working with Filters ~ 363
Performance Tuning ~ 365
Saving the Result ~ 366
Using the DirectPlay Network Simulator ~ 367
Using the MeshView Tool ~ 369
Creating a Mesh ~ 369
Adding Color ~ 370
Making Other Changes ~ 373
Using a Mesh Example ~ 376
Initializing the Application ~ 376
Loading a Mesh File ~ 377
Displaying the Image On Screen ~ 380
A Few Words about Output ~ 383
Where Do You Go from Here? ~ 385

Part V: Appendices ~ 387

Appendix A: Fifty-Two Tips for Error-Free Win32 API Access ~ 388

Appendix B: Fixes for Common API Access Errors ~ 393
Resolving Data Corruption in Data Structures ~ 393
The [DllImport] Attribute Works Improperly ~ 394
Data Transfer Problems ~ 394
.NET Implementation of COM Interface Doesn't Work ~ 396
Handling Memory Leaks and Other Resource Problems ~ 396
Windows Doesn't Appear to Handle Messages Correctly ~ 397

Glossary ~ 399
B ~ 399
C ~ 400
D ~ 401
E ~ 402
F ~ 403
G ~ 404
H ~ 404
I ~ 405
L ~ 405
M ~ 406
N ~ 407
P ~ 408
R ~ 409
S ~ 409
T ~ 410
U ~ 411
V ~ 412
W ~ 413

List of Figures ~ 415
Chapter 1: Overcoming Holes in the .NET Framework ~ 415
Chapter 2: Working with Win32 API Data ~ 415
Chapter 3: Accessing the Win32 API ~ 415
Chapter 4: Processing Windows Messages ~ 415
Chapter 5: Using Callback Functions ~ 416
Chapter 6: Gaining Support for the Console Application ~ 416
Chapter 7: Accessing the Hardware Directly ~ 416
Chapter 8: Overcoming Security Issues ~ 416
Chapter 9: Accessing Windows XP Special Features ~ 417
Chapter 10: Using Operating System Special Functions ~ 417
Chapter 11: Accessing the Media Player ~ 417
Chapter 12: Working with Microsoft Management Console ~ 418
Chapter 13: Creating DirectX Structures and Data Elements ~ 418
Chapter 14: Developing DirectX Access Routines ~ 418
Chapter 15: Creating Applications with DirectX 8.1 ~ 418
Chapter 16: Extended DirectX Programming Examples ~ 419

List of Sidebars ~ 420
Chapter 2: Working with Win32 API Data ~ 420
Chapter 3: Accessing the Win32 API ~ 420
Chapter 8: Overcoming Security Issues ~ 420
Chapter 10: Using Operating System Special Functions ~ 420
Chapter 13: Creating DirectX Structures and Data Elements ~ 420
Chapter 15: Creating Applications with DirectX 8.1 ~ 420

List of Tables ~ 421
Chapter 4: Processing Windows Messages ~ 421
Chapter 8: Overcoming Security Issues ~ 421

List of Listings ~ 422
Chapter 1: Overcoming Holes in the .NET Framework ~ 422
Chapter 2: Working with Win32 API Data ~ 422
Chapter 3: Accessing the Win32 API ~ 422
Chapter 4: Processing Windows Messages ~ 422
Chapter 5: Using Callback Functions ~ 422
Chapter 6: Gaining Support for the Console Application ~ 422
Chapter 7: Accessing the Hardware Directly ~ 423
Chapter 8: Overcoming Security Issues ~ 423
Chapter 9: Accessing Windows XP Special Features ~ 423
Chapter 10: Using Operating System Special Functions ~ 423
Chapter 11: Accessing the Media Player ~ 423
Chapter 12: Working with Microsoft Management Console ~ 424
Chapter 13: Creating DirectX Structures and Data Elements ~ 424
Chapter 14: Developing DirectX Access Routines ~ 424
Chapter 15: Creating Applications with DirectX 8.1 ~ 424
Chapter 16: Extended DirectX Programming Examples ~ 424