Win Shell API

Windows 2000 Edition

John Ayres

Wordware Publishing, Inc.

Library of Congress Cataloging-in-Publication Data Ayres, John.

Tomes of Delphi : Win32 Shell API—Windows 2000 edition / by John Ayres.

p. cm. Includes index.

ISBN 1-55622-749-3 (paperback)

  1. Microsoft Win32. 2. Delphi (Computer file). I. Title.
  2. 76.063 A98 2002
  3. 265--dc21 2002004006

© 2002, Wordware Publishing, Inc.

All Rights Reserved

2320 Los Rios Boulevard Plano, Texas 75074

No part of this book may be reproduced in any form or by any means without permission in writing from Wordware Publishing, Inc.

Printed in the United States of America

ISBN 1-55622-749-3 10 987654321 0204

Delphi is a trademark of Borland Software Corporation in the United States and other countries. Windows is a registered trademark of Microsoft Corporation in the United States and/or other countries. Other products mentioned are used for identification purposes only and may be trademarks of their respective companies.

All inquiries for volume purchases of this book should be addressed to Wordware Publishing, Inc., at the above address. Telephone inquiries may be made by calling:


Praise for John Ayres' Tomes of Delphi books

"The Tomes of Delphi is the definitive reference for the Win32 API expressed in the Object Pascal language. It's a must-have for application and component developers looking to extend their reach beyond the capabilities of the Visual Component Library."

Steve Teixeira, Director Core Technology

Zone Labs, Inc. and co-author of Delphi 6 Developer's Guide

"Delphi lets developers work 'under the hood' with the Win32 API. The Tomes of Delphi 3: Win32 Core API gives every Delphi developer the knowledge to use the Win32 API powerfully, creatively, and effectively."

Michael Swindell, Director of Product Management RAD Tools Group, Borland Software Corporation

"The Tomes of Delphi 3: Win32 Core API is my number one resource when looking for information about how to use the Win32 core API in Delphi. I especially enjoy the helpfile that contains the complete text from the book and can be accessed directly when programming."

Bob Swart (a.k.a. "Dr. Bob"), Author, trainer, consultant

"Not only were these the first Delphi books to concentrate on API-level programming, they set the standard for all future Delphi API books. With the increasing importance of the shell API for Windows developers, this is the perfect update for this classic Delphi work."

Alan C. Moore, Contributing Editor Delphi Informant Magazine


To my second daughter, Victoria Ann Ayres. The entirety of this book was written while she and her mother were still a part of each other. As that miraculous day approaches when I can finally meet her face to face and welcome her to our world, my panic is slowly being replaced with incredible joy and wonder. Children are indeed a miracle, and I am very thankful for this gift from God that we shall soon receive. The responsibility of parenthood can be demanding at times, but it is very rewarding, and I am doubly blessed for the opportunity to once again shape the future of one who is sure to grow into an incredible person. Hero, mentor, role model, playmate, dance partner, confidant, keeper of secrets, and healer of wounds — all these things and much, much more add up to fatherhood. I hope to live up to my daughter's expectations of a father, and may she grow to be more than the sum of her parents.


Foreword xvii

Acknowledgments xix

Introduction xxi

Chapter 1 Delphi and the Windows API 1

Windows Data Types 1

Handles 4

Constants 4

Strings 4

Importing Windows Functions 4

Incorrectly Imported Functions 5

Callback Functions 5

Function Parameters 6

Unicode 7

Delphi vs. the Windows API 7

Chapter 2 Window Movement Functions 9

Z-order 9

Special Effects 10

Delphi vs. the Windows API 11

Window Movement Functions 12

AdjustWindowRect 12

AdjustWindowRectEx 14

BeginDeferWindowPos 15

BringWindowToTop 17

CascadeWindows 18

CloseWindow 19

DeferWindowPos 20

EndDeferWindowPos 23

GetWindowPlacement 23

MoveWindow 24

OpenIcon 25

SetWindowPlacement 26

SetWindowPos 29

ShowOwnedPopups 32

ShowWindow 33

ShowWindowAsync 35

TileWindows 37

Chapter 3 Window Information Functions 39

Information Storage 39

Window-specific Information 40

Subclassing a Window 41

Knowing It All 42

Delphi vs. the Windows API 48

Window Information Functions 49

AnyPopup 50

ChildWindowFromPoint 51

ChildWindowFromPointEx 52

EnableWindow 54

EnumChildWindows 55

EnumProps 57

EnumPropsEx 60

EnumThreadWindows 63

EnumWindows 65

FindWindow 67

FindWindowEx 68

FlashWindow 69

GetActiveWindow 70

GetClassInfo 70

GetClassInfoEx 72

GetClassLong 75

GetClassName 77

GetClientRect 78

GetDesktopWindow 79

GetFocus 80

GetForegroundWindow 80

GetNextWindow 82

GetParent 83

GetProp 84

GetTopWindow 84

GetWindow 85

GetWindowLong 87

GetWindowRect 90

GetWindowText 90

GetWindowTextLength 92

IsChild 92

IsIconic 94

IsWindow 94

IsWindowEnabled 95

IsWindowUnicode 95

IsWindowVisible 96

IsZoomed 97

RemoveProp 98

SetActiveWindow 98

SetClassLong 99

SetFocus 101

SetForegroundWindow 102

SetParent 102

SetProp 104

SetWindowLong 104

SetWindowText 106

WindowFromPoint 107

Chapter 4 File Input/Output Functions 109

File Creation 109

File Times 110

Delphi vs. the Windows API 110

File Input/Output Functions 111

CloseHandle 112

CompareFileTime 113

CopyFile 115

CreateDirectory 117

CreateDirectoryEx 119

CreateFile 120

CreateFileMapping 126

DeleteFile 132

DosDateTimeToFileTime 133

FileTimeToDosDateTime 134

FileTimeToLocalFileTime 135

FileTimeToSystemTime 135

FindClose 140

FindCloseChangeNotification 140

FindFirstChangeNotification 141

FindFirstFile 143

FindNextChangeNotification 147

FindNextFile 148

FlushFileBuffers 149

FlushViewOfFile 149

GetCurrentDirectory 150

GetFileAttributes 151

GetFileInformationByHandle 152

GetFileSize 155

GetFileTime 156

GetFileType 156

GetFileVersionInfo 157

GetFileVersionInfoSize 158

GetFullPathName 159

GetShortPathName 159

GetTempFileName 160

GetTempPath 162

LocalFileTimeToFileTime 163

LockFile 164

MapViewOfFile 165

MoveFile 166

OpenFileMapping 167

ReadFile 168

RemoveDirectory 170

SearchPath 170

SetCurrentDirectory 171

SetEndOfFile 172

SetFileAttributes 173

SetFilePointer 177

SetFileTime 178

SystemTimeToFileTime 179

UnlockFile 180

UnMapViewOfFile 181

VerQueryValue 181

WriteFile 188

Chapter 5 Input Functions 191

The Keyboard 191

The Mouse 192

Delphi vs. the Windows API 192

Input Functions 192

ActivateKeyboardLayout 194

ClipCursor 195

DragDetect 195

GetAsyncKeyState 197

GetCapture 198

GetCaretBlinkTime 198

GetCaretPos 199

GetClipCursor 199

GetCursorPos 200

GetDoubleClickTime 200

GetInputState 201

GetKeyboardLayout 201

GetKeyboardLayoutList 202

GetKeyboardLayoutName 202

GetKeyboardState 203

GetKeyboardType 204

GetKeyNameText 206

GetKeyState 208

keybd_event 209

joyGetDevCaps 211

joyGetNumDevs 213

joyGetPos 214

joyGetPosEx 215

joyGetThreshold 218

joyReleaseCapture 219

joySetCapture 220

joySetThreshold 224

LoadKeyboardLayout 225

MapVirtualKey 228

MapVirtualKeyEx 230

mouse_event 231

OEMKeyScan 234

ReleaseCapture 235

SetCapture 235

SetCaretBlinkTime 236

SetCaretPos 238

SetCursorPos 238

SetDoubleClickTime 239

SetKeyboardState 240

SwapMouseButton 240

UnloadKeyboardLayout 244

VkKeyScan 244

VkKeyScanEx 245

Chapter 6 String and Atom Functions 249

Atom Tables 249

String Formatting 250

Delphi vs. the Windows API 250

String and Atom Functions 251

AddAtom 252

CharLower 253

CharLowerBuff 255

CharNext 256

CharPrev 257

CharToOem 257

CharToOemBuff 259

CharUpper 259

CharUpperBuff 260

CompareString 261

DeleteAtom 265

EnumSystemCodePages 266

EnumSystemLocales 268

FindAtom 270

FormatMessage 270

GetACP 276

GetAtomName 279

GetCPInfo 280

GetCPInfoEx 281

GetDateFormat 282

GetOEMCP 286

GetTimeFormat 288

GlobalAddAtom 291

GlobalDeleteAtom 293

GlobalFindAtom 293

GlobalGetAtomName 294

InitAtomTable 295

IsCharAlpha 295

IsCharAlphaNumeric 296

IsCharLower 297

IsCharUpper 297

lstrcat 298

lstrcmp 299

lstrcmpi 301

lstrcpy 302

lstrlen 303

MakeIntAtom 303

OemToChar 305

OemToCharBuff 305

ToAscii 306

wvsprintf 307

Chapter 7 Clipboard Manipulation Functions 313

Clipboard Internals 313

Conversion Formats 314

Delayed Rendering 314

Clipboard Viewers 317

Delphi vs. the Windows API 317

Clipboard Manipulation Functions 317

ChangeClipboardChain 318

CloseClipboard 319

CountClipboardFormats 319

EmptyClipboard 320

EnumClipboardFormats 320

GetClipboardData 322

GetClipboardFormatName 325

GetClipboardOwner 325

GetClipboardViewer 326

GetOpenClipboardWindow 326

GetPriorityClipboardFormat 327

IsClipboardFormatAvailable 328

OpenClipboard 329

RegisterClipboardFormat 330

SetClipboardData 330

SetClipboardViewer 335

Chapter 8 System Information Functions 339

Accessibility Features 339

Delphi vs. the Windows API 341

System Information Functions 341

ExpandEnvironmentStrings 342

FreeEnvironmentStrings 344

GetCommandLine 344

GetComputerName 345

GetDiskFreeSpaceEx 345

GetDriveType 347

GetEnvironmentStrings 348

GetEnvironmentVariable 349

GetLocaleInfo 350

GetLocalTime 359

GetLogicalDrives 360

GetLogicalDriveStrings 362

GetStartupInfo 363

GetSystemDefaultLangID 364

GetSystemDefaultLCID 365

GetSystemDirectory 366

GetSystemInfo 367

GetSystemTime 371

GetSystemTimeAsFileTime 371

GetTimeZoneInformation 372

GetUserDefaultLangID 375

GetUserDefaultLCID 375

GetUserName 376

GetVersionEx 377

GetVolumeInformation 379

GetWindowsDirectory 382

IsProcessorFeaturePresent 383

SetComputerName 385

SetEnvironmentVariable 386

SetLocaleInfo 388

SetLocalTime 393

SetSystemTime 395

SetTimeZonelnformation 396

SetVolumeLabel 397

SystemParametersInfo 398

VerLanguageName 433

Chapter 9 Icon, Cursor, and Caret Functions 437

Carets 437

Icon and Cursor Masks 438

Icon to Bitmap Conversion 439

Delphi vs. the Windows API 442

Icon, Cursor, and Caret Functions 442

CopyIcon 443

CreateCaret 444

CreateCursor 446

CreateIcon 448

CreateIconFromResource 451

CreateIconFromResourceEx 453

CreateIconIndirect 455

DestroyCaret 457

DestroyCursor 458

DestroyIcon 458

DrawIcon 459

DrawIconEx 459

ExtractAssociatedIcon 461

ExtractIcon 462

ExtractIconEx 464

GetCursor 467

GetIconInfo 467

HideCaret 471

LoadCursor 471

LoadCursorFromFile 472

LoadIcon 474

LookupIconIdFromDirectory 475

LookupIconIdFromDirectoryEx 475

SetCursor 477

SetSystemCursor 477

ShowCaret 479

ShowCursor 479

Chapter 10 Help Functions 481

WinHelp 481

WinHelp Architecture 482

Creating a WinHelp Help File 482

Using WinHelp 482

Advantages/Disadvantages 484

HTMLHelp 485

HTMLHelp Architecture 485

Creating an HTMLHelp Help File 485

Using HTMLHelp 486

Advantages/Disadvantages 490

Delphi vs. the Windows API 491

Help Functions 491

HTMLHelp 491

WinHelp 509

Chapter 11 Shell File Functions 513

File-based Applications 513

Structured Storage 517

Creating and Reading Structured Storage Files 517

Transacted Storage Files 518

Delphi vs. the Windows API 529

Shell File Functions 529

DragAcceptFiles 530

DragFinish 532

DragQueryFile 532

DragQueryPoint 534

FindExecutable 534

  1. Commit 537
  2. CopyTo 539
  3. CreateStorage 540
  4. CreateStream 543
  5. DestroyElement 545
  6. EnumElements 546
  7. MoveElementTo 549
  8. OpenStorage 552
  9. OpenStream 554
  10. RenameElement 556
  11. Revert 557
  12. SetClass 557
  13. Stat 558
  14. Clone 560
  15. CopyTo 561
  16. Read 562
  17. Seek 563
  18. SetSize 564
  19. Stat 565
  20. Write 566

SHAddToRecentDocs 567

SHFileOperation 569

SHFreeNameMappings 574

SHGetFileInfo 574

StgCreateDocFile 579

StgIsStorageFile 582

StgOpenStorage 583

Chapter 12 Shell Folder Functions 587

Browsing for Folders 587

Item Identifier Lists 589

Delphi vs. the Windows API 589

Shell Folder Functions 589

SHBrowseForFolder 590

SHEmptyRecycleBin 595

SHGetFolderLocation 597

SHGetFolderPath 601

SHGetPathFromIDList 605

SHGetSettings 605

SHGetSpecialFolderLocation 607

SHGetSpecialFolderPath 611

SHQueryRecycleBin 614

Chapter 13 Shell Extension Functions 617

Shell Extension Basics 617

Creating the COM Object 618

Implementing Interface Methods 619

Registering the Shell Extension 619

URL Search Hook Shell Extensions 619

Implementing URL Search Hook Shell Extensions 620

Registering URL Search Hook Shell Extensions 620

Infotip Shell Extensions 622

Implementing Infotip Shell Extensions 622

Registering Infotip Shell Extensions 623

Copy Hook Shell Extensions 627

Implementing Copy Hook Shell Extensions 627

Registering Copy Hook Shell Extensions 627

Shell Execute Hook Shell Extensions 630

Implementing Shell Execute Hook Shell Extensions 631

Registering Shell Execute Hook Shell Extensions 631

Context Menu Handler Shell Extensions 634

Implementing Context Menu Handler Shell Extensions 634

Registering Context Menu Handler Shell Extensions 635

Icon Handler Shell Extensions 639

Implementing Icon Handler Shell Extensions 640

Registering Icon Handler Shell Extensions 640

Drag-Drop Handler Shell Extensions 644

Implementing Drag-Drop Handler Shell Extensions 644

Registering Drag-Drop Handler Shell Extensions 645

Delphi vs. the Windows API 651

Shell Extension Functions 651

  1. GetCommandString 651
  2. InvokeCommand 652
  3. QueryContextMenu 655
  4. CopyCallback 656
  5. DragEnter 658
  6. DragLeave 660
  7. DragOver 660
  8. Drop 661
  9. Extract 663
  10. GetIconLocation 663
  11. GetInfoFlags 665
  12. GetInfoTip 665
  13. Execute 666
  14. Initialize 670
  15. Translate 671

Chapter 14 Specialized Shell Functions 673

Control Panel Applications 673

The CplApplet Function 673

Control Panel Messages 674

Writing Control Panel Applications 675

Application Bars 678

Tray Icon Applications 681

Creating a Tray Icon Application 682

Messages 682

Balloon Tooltips 682

Delphi vs. the Windows API 685

Specialized Shell Functions 685

CplApplet 686

  1. Alloc 689
  2. DidAlloc 691
  3. Free 691
  4. GetSize 692
  5. HeapMinimize 692
  6. Realloc 693

SHAppBarMessage 693

SHChangeNotify 698

ShellAbout 702

ShellExecute 703

ShellExecuteEx 706

Shell_NotifyIcon 712

SHGetMalloc 717

Appendix A Bibliography 719

Appendix B Virtual Key Code Chart 721

Appendix C Tertiary Raster Operation Codes 725

Appendix D ASCII Character Set 733

Index 737


The Windows API is the foundation upon which most contemporary programs are built. It is the heart and soul of database applications, multimedia applications, even many network based applications. Every Windows application relies on the Windows API to perform everything from the most mundane to the most esoteric task.

All of the good programmers I know have a solid foundation in the Windows API. It is the language in which the architecture of the Windows operating system is most eloquently expressed, and it holds the secrets programmers need to know if they want to develop powerful, well tuned applications.

There are at least three reasons why most serious programmers need to know the Windows API:

  1. It is occasionally possible to write strong, robust applications without having a good understanding of the Windows API. However, there comes a time in the course of most application development projects when you simply have to turn to the Windows API in order to solve a particular problem. Usually this happens because a tool you are using does not have a feature you need, or because the feature is not implemented properly. In such cases, you have to turn to the Windows API in order to implement the feature yourself.
  2. Another reason to use the Windows API surfaces when you want to create a component or utility that others can use. If you want to build a component, ActiveX control, or simple utility that will perform a useful function needed by other developers or power users, then you probably will need to turn to the Windows API. Without recourse to the Windows API, such projects are usually not feasible.
  3. The final and best reason for learning the Windows API is that it helps you see how you should architect your application. We have many high-level tools these days that let us build projects at a very remote, and powerful, level of abstraction. However, each of these tools is built on top of the Windows API, and it is difficult, if not impossible, to understand how to use them without understanding the architecture on which they are founded. If you understand the Windows API then you know what the operating system can do for you, and how it goes about providing that service. With this knowledge under your belt, you can use high-level tools in an intelligent and thoughtful manner.

I am particularly pleased to see the publication of Wordware's books on the Windows API because they are built around the world's greatest development tool: Delphi. Delphi gives you full access to the entire Windows API. It is a tool designed to let you plumb the depths of the operating system, to best utilize the features that have made Windows the preeminent operating system in the world today.

Armed with these books on the Windows API, and a copy of Delphi, you can build any type of application you desire, and can be sure that it is being constructed in the optimal possible manner. No other compiler can bring you closer to the operating system, nor can any other compiler let you take better advantage of the operating system's features. These books are the Rosetta stone which forms the link between Delphi and the Windows API. Readers will be able to use them to create the most powerful applications supported by the operating system. My hat is off to the authors for providing these books as a service to the programming community.

Charles Calvert former Borland Developer Relations Manager


This project would not have been completed without the help of many generous, caring people. In an effort to give credit to those who deserve so much more, the author would like to thank the following people, in no particular order, for their contributions to the book:

Jim Hill, Wes Beckwith, and all the good people down at Wordware Publishing for giving me a platform from which I can do my part to further the overall Delphi community.

Marci Ayres, who performed a lot of code testing, grayscale image conversion, document formatting, and other support functions, along with putting together the help file. This book was written through her entire second pregnancy, and even through all the discomforts that accompany carrying a child, she took over all of my domestic duties so I could concentrate on finishing this book.

Rusty Cornett, who was responsible for introducing me to Delphi and opening up a very rewarding career path.

The authors of the original Tomes of Delphi series, who collectively put in many hours for those first two books.

Of course, no acknowledgment would be complete without thanking the Delphi development staff at Borland for giving all of us such an awesome development tool.


The Windows programming environment. No other operating system in history has caused so much controversy or confusion among the programming industry. Of course, no other operating system in history has made so many millionaires either. Like it or not, Windows is here to stay. It's hard to ignore such a large user base, and there are few job opportunities anymore that do not require the programmer to have knowledge of the Windows environment.

In the beginning, a programmer's only choice of tools for creating Windows applications was C/C++. The age of this language has resulted in a wealth of Windows API documentation, filled with abstract and incomplete information, and examples that are as esoteric and arcane as the C language itself. Then along came Delphi. A new era in Windows programming was born, with the ability to easily create complex and advanced Windows applications with a turnaround time unheard of previously. Although Delphi tries its best to insulate the programmer from the underlying Windows architecture, Delphi programmers have found that some programming obstacles simply cannot be overcome without using low-level Windows API functions. Although there have been a few books that touched on the subject of using Windows API functions in Delphi, none have ever discussed the issue in depth. There are numerous magazine articles that describe very specific subsets of the API, but unless the Delphi programmer has a background in C and the time to convert a C example into Delphi, there was simply no recourse of action. Thus, this book was born.

This book is a reference manual for using Windows 32-bit API functions in the Delphi environment. As such, it is not a Windows or Delphi programming tutorial, nor is it a collection of Delphi tricks that solve specific problems. To date, this book is the most complete and accurate reference to the Windows API for the Delphi programmer. It is not a complete reference, as the Windows API includes thousands upon thousands of functions that would fill many volumes much larger than the one you are holding. However, this book covers the most common and important cross section of the Windows API. Additionally, almost every function in this book is available under Windows 95\98\Me and Windows NT\2000\XP (exceptions are noted).

The Chapters

I Chapter 1: Delphi and the Windows API

This chapter introduces the reader to The Tomes of Delphi: Win32 Shell API — Windows 2000 Edition. It covers general Windows programming concerns and techniques, and explains various nuances of programming with the Win32 API in the Delphi environment.

I Chapter 2: Window Movement Functions

Controlling a window's position can be an important part of a complex user interface. This chapter covers those functions used to control a window's position and size. Examples include moving multiple windows simultaneously and retrieving window positioning and size information.

I Chapter 3: Window Information Functions

The developer may need to programmatically query a window for some piece of information. This chapter covers functions used to retrieve information on specific windows, such as a window's size, position, and attributes. Examples include subclassing a window and changing window attributes at run time.

I Chapter 4: File Input/Output Functions

Most applications need the ability to read and write information to an external storage device, and this chapter covers the functions used to manipulate disk-based files. Examples include creating files, manipulating file attributes, reading and writing to a file at the binary level, and performing a file search.

I Chapter 5: Input Functions

Without the functionality to interpret user input, most applications would be relatively useless. This chapter covers functions used to receive input from the user, such as keyboard and mouse input. Examples include receiving input from the joystick, retrieving information about the keyboard, and manipulating the cursor.

I Chapter 6: String and Atom Functions

All applications need to display information to the user, which usually takes place in the form of a string. This chapter covers string manipulation functions and functions used to allocate and remove global atoms. Examples include formatting messages, manipulating atoms and strings.

I Chapter 7: Clipboard Functions

The ability to share information between applications through copy and paste is an expected requirement from Windows users. This chapter covers the functions used to manipulate and view the contents of the clipboard. Examples including enumerating clipboard formats, registering a new clipboard format, and viewing the clipboard contents.

I Chapter 8: System Information Functions

It may sometimes be useful to retrieve specific information about the system or hardware that is running an application. This chapter covers functions used to query the system for information. Examples include retrieving system hardware information and environment variables, and modifying system parameters.

I Chapter 9: Icon, Cursor, and Caret Functions

Icons, carets, and cursors are also fundamental graphics objects. This chapter describes the functions used to create and manipulate icons, cursors, and carets. Examples include extracting icons from external files, manipulating the caret, and creating new cursors.

I Chapter 10: Help Functions

An application without a help system is not a finished application. This chapter covers the two API functions that interface with the help system: WinHelp and HTMLHelp. Several examples are included for both.

I Chapter 11: Shell File Functions

The Windows environment provides many system-level functions that can be very useful when manipulating files. This chapter covers those functions used to copy and move files and retrieve file information. Examples include creating an appbar application, copying and moving files, and querying file information.

I Chapter 12: Shell Folder Functions

The Windows namespace includes many special folders that have specific meaning within the shell. This chapter examines the many functions that interact with folders at the shell level. Examples include using the Browse for Folder dialog box and manipulating the recycle bin.

I Chapter 13: Shell Functions

Windows functionality can be extended through the use of shell hooks and extensions. This chapter discusses methods to implement many common and useful shell extension interfaces. Examples include a dynamic icon extractor and context menu handler.

I Chapter 14: Specialized Shell Functions

Many shell functions do not fit into a specific category. This chapter examines several unique shell functions that could not be classified into other chapters. Examples include a control panel applet and an appbar.


Certain writing conventions have been used throughout this book to convey specific meanings. All example code throughout each chapter appears in a monotype font, such as:

function HelloThere(Info: string): Integer; begin

ShowMessage(Info); end;

In order to be consistent with other works on Delphi programming, the example code uses Borland's coding conventions, which includes using mixed case for variable names and identifiers, lowercase for reserved words, and nested code indented two spaces per level. Any constants used in the code will appear in all capitals, such as TRUE and FALSE. Also, notice that the name of the unit that contains an individual function is located on the same line as the function name. This unit must be included in the Uses clause of any unit in which this function is used. However, most of the functions covered in this series are located in the Windows.pas file, which is automatically added to the Uses clause by Delphi. In addition, when the text refers to a window, as in a visual object on the screen, the word "window" will begin with a lowercase letter. When the text refers to Windows, as in the operating system, the word "Windows" will be capitalized.

Function Descriptions

The Windows API function descriptions have been laid out in a format that provides an increasing amount of detail to the reader. This should allow the reader to quickly glance at a function description for a simple reminder of required parameters, or to read further for a detailed explanation of the function, an example of its use, and any acceptable constant values used in a parameter.

Each function description includes the exact syntax found in the Delphi source code, a description of what the function does, a detailed list and description of the function's parameters, the value returned from the function, a list of related functions, and an example of its use. Any defined constants used in a function parameter are found in tables that follow the example, so that the descriptive text of the function is not broken by a distraction, and all of the constants are available in one place for easy perusal. Some tables may be repeated under various functions that use the same parameters. This was done to eliminate the need to flip back and forth between several pages while perusing the function descriptions. An asterisk (*) indicates the function is covered in The Tomes of Delphi: Win32 Core API— Windows 2000 Edition.

Sample Programs

Although every book reaches a point where the authors are frantically hacking away at the text trying to meet deadlines, I did not want the example code to suffer due to time restraints. Unlike some other books, I wanted to make sure that the example code worked in every case. Therefore, I have taken every effort to ensure that the source code on the companion CD works as expected and that the code found in the book is the exact code found on the CD. This should guarantee that code entered straight from the text will work as described. However, most of the code examples rely on buttons, edit boxes, or other components residing on the form, which may not be apparent from the code listing. When in doubt, always look at the source code included on the CD. Also, bear in mind that some examples may only work under certain conditions; for example, many of the examples demonstrating graphical API calls will only work correctly under a 256-color video mode.

Who This Book is For

Due to the nature of reference manuals and the lack of any involved explanations into general Windows or Delphi programming, this book is intended for use by experienced Delphi programmers with a working knowledge of Windows programming. This is not to say that intermediate or even beginning Delphi programmers will not benefit from this book; in fact, there are quite a few example programs included that solve a number of everyday programming conundrums. The heavily documented examples should provide enough explanation for even the most neophyte Delphi programmer to gain some understanding of the API function being demonstrated. As a reference manual, the book is not intended to be read sequentially from cover to cover. However, the chapters have been laid out in a logical order of progression, starting with the most fundamental Windows API functions and working towards the more specialized functions.

If you are looking for an introduction to Delphi programming, or a step-by-step Windows programming tutorial, there are plenty of other fine books out there to get you started. However, if you've got a nasty problem whose only hope of salvation is using the Windows API, if you want to extend the functionality of Delphi components and objects, or if you want a down-and-dirty, no-holds-barred collection of Delphi Win32 API programming examples, then this book is for you. You will not find a more complete and accurate guide to the Win32 API for the Delphi programmer.

Chapter 1

+1 0


  • Celendine
    Where can i find delphi shell api?
    6 months ago

Post a comment