Lập trình C++ với Windows và Shell
Lập trình C++ với Windows và Shell. Tài liệu bằng tiếng anh, xem và tham khảo.
Visual C++
Windows Shell Programming
Dino Esposito
Wrox Press Ltd.
Visual C++ Windows Shell Programming
© 1998 Wrox Press
All rights reserved. No part of this book may be reproduced, stored in a retrieval system or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embodied in critical articles or reviews.
The author and publisher have made every effort in the preparation of this book to ensure the
accuracy of the information. However, the information contained in this book is sold without
warranty, either express or implied. Neither the authors, Wrox Press nor its dealers or
distributors will be held liable for any damages caused or alleged to be caused either directly
or indirectly by this book.
Published by Wrox Press Ltd. 30 Lincoln Road, Olton, Birmingham, B27 6PA
Printed in USA
ISBN 1-861001-8-43
Trademark Acknowledgements
Wrox has endeavored to provide trademark information about all the companies and products
mentioned in this book by the appropriate use of capitals. However, Wrox cannot guarantee
the accuracy of this information.
Credits
Author Cover
Dino Esposito Andrew Guillaume
Concept by Third Wave
Development Editor
John Franklin Design/Layout
Noel Donnelly
Editors
Jon Hill Index
Chris Hindley Andrew Criddle
Technical Reviewers
Davide Marcato
Tommy Riddle
Kenn Scribner
Marc Simkin
Mark Stiver
Julian Templeman
Keep it simple: as simple as possible, but no simpler.
Albert Einstein
Photo of the ammonite courtesy of Claren Kidd at the
Laurence S Youngblood Energy Library, University of Oklahoma.
http://www-lib.ou.edu/depts/geol/lammonite.html
About the Author
Dino Esposito is a senior consultant who specializes in Windows and COM development. At
present, his work for Andersen Consulting focuses on the development of Web-based
applications. He's a frequent speaker at industry conferences such as Microsoft Developer Days
and occasionally holds seminars for Mondadori Informatica Education.
He also has extensive experience developing commercial Windows-based software, especially
for the photography world, and was part of the team who designed and realized one of the first
European image databanks.
Dino loves writing, and is a contributing editor to Microsoft Internet Developer for which he runs
the Cutting Edge column. He contributes to a number of magazines including Microsoft Systems
Journal, MSDN News, Windows Developer's Journal, Dr. Dobb's Journal and a number of Italian
magazines. He co-authored Professional IE4 Programming and authored Instant DHTML Scriptlets,
both published by Wrox Press.
Dino lives in Rome (Italy) with his wife Silvia and a six-month-old son, Francesco. Feel free to
contact him at [email protected].
Acknowlegements
Even though I appear smiling and relaxed on the cover, believe me, doing this book was no
picnic. It's been a pleasure, though. I've really enjoyed presenting my development experience
and telling you about all the pitfalls I've found along the way. My hope is that, with this book,
your coding will progress more quickly.
I said it wasn't easy, and didn't just mean for myself. Silvia, my wife, was incredibly patient
with me and many nights, at the end of a chapter, I found her solicitously awake. This book
considerably increased her capacity to sleep in spite of the typical but annoying noise of a
programmer: the unremitting clicking, plop and plonk, dialing and so on. There's nothing to
do, I really love you – and it's rhymed too!
No, Francesco, don't cry! Daddy loves you too. Francesco is now six months old and shows a
great interest for everything with buttons, from keyboards to remote controls and from
telephones to cameras. He's a very lively and precocious baby. Although his name doesn't
appear among the technical reviewers, he really gave a considerable contribution to the last
two chapters. (Jon, now you know the real reason why you got them so late…)
Jon Hill was the lead technical editor of this book and, let me say, did an excellent job testing
and re-testing the source code, providing countless pieces of good advice and, above all,
addressing the weak points in the original text. You'll never know about them, but believe me,
the book is now far more readable, rich and enjoyable. Thank you, Jon!
And thanks also to all the guys that reviewed the various chapters. In particular, I'd like to
mention Kenn Scribner who led me to discover and consider a number of neglected topics.
Thank you, Kenn; I appreciated your ideas very much.
Other people contributed to this book with their suggestions and technical tips. I want to say
thanks to Marco Losavio, Graziano Lorusso, Giuseppe Dimauro, Francesco Balena, Carlo
Pescio and Antonio Derossi.
Writing a book related to Windows necessarily involves pinging people at Microsoft, searching
for help, tips, references and so forth. Among others, I'd like to mention Scott Roberts, Andrew
Clinick and Michael Edwards who clarified a number of obscure points and helped me to find
up-to-date information. Scott was incredibly kind and patient and even answered my questions
over some weekends. I'm really grateful. I'll write it in Italian too: Te ne sono veramente molto
grato.
Other people at Microsoft provided assistance, directly or indirectly. In no particular order:
Josh Trupin and Joe Flanigen, for their appreciation and continued encouragement, and with
them all the staff at MIND and MSJ. Paula Ladenburg, for giving me the opportunity to appear
on MSDN and astound friends and colleagues with public full-text search engines. Joanne
Steinhart, for providing me with the colorful MIND mousepad that many times has captured
Francesco's attention and allowed me to work a bit more quietly.
Writing a book is just one aspect of my daily activity. Thus, I want to reserve a special mention
for the people at Andersen Consulting. In particular, I want to thank Bruno Ronchetti and
Giorgio Di Paolo for the opportunities they offered me and the patience they always
demonstrated.
Thanks also to Natale Fino and Roberto Palumbo at Infomedia. Their magazines are probably
the only chance I have not to forget how to write in Italian!
I love writing, but speaking is another thing that lets you touch what's going on in development
today. For this, I wish to mention Stefano Maruzzi and Alessandro Pedone at Mondadori
Informatica Education.
A word written a few lines above now is striking me: weekend. What's that? I think I'll have to
do some research to figure it out. When you work so hard month after month, sooner or later
you end up neglecting friends. To try to partially remedy this, I want to embrace in a common
thought Marco Lucani, Raffaele D'Orsogna, Roberto Raschetti and my brother Telly.
Last but not least, I would like to thank the person who is somewhat responsible for this book:
John Franklin. I enjoyed writing this book, despite the hard work. You and your team made it
really pleasant.
Thanks to you all
Dino
Table of Contents
Introduction 1
Everything Changes 1
What Does this Book Cover? 2
What You Need to Use this Book 2
Conventions Used 3
Tell Us What You Think 3
Source Code 4
Support 4
Chapter 1: What is the Windows Shell? 7
The Components of the Shell 8
The Program Manager 8
The Taskbar 9
The Desktop 9
The Structure of Explorer 9
Injection Points for Extensions 10
Extensions to Explorer 10
Why Program the Shell? 10
Where This Book Will Take You 11
The Plethora of Shell Versions 12
Where is the Official Documentation? 13
Summary 13
Chapter 2: The Structure of the Shell 15
The Pieces of the Shell 16
The Shell's Namespace 16
Folders 17
File Objects 18
PIDLs 19
The Shell's View 21
Table of Contents
Hooking the Shell 21
The Shell's Address Space 22
The Shell's Memory Allocator 22
The Shell's Taskbar 22
The Shell API Functions 23
General Windows Functions 24
Shell Internals 25
Taskbar Functions 25
File Functions 25
Folder Functions 26
Icon Functions 27
The COM Interfaces 27
Shell Interfaces 27
Namespace Interfaces 28
Hook Interfaces 29
Miscellaneous Interfaces 29
Why the API? Why COM? 30
What Changed with Active Desktop 30
The New Shell View Object 31
Customizing a Folder 33
The New Taskbar Layout 34
Summary 35
Chapter 3: Working with Files 37
What Can SHFileOperation() do for You? 38
How SHFileOperation() Works 39
Available Operations 39
Pay Attention to the Double-NULL 40
Moving and Copying Files 41
Deleting Files 50
Renaming Files 52
SHFileOperation() Return Values 53
Two Poor Man's Utilities for Surviving Error Messages 54
Did Everything Really Work Properly? 56
Long File Names 56
File Name Mapping Objects 57
Demonstrating File Mapping 58
Using the Object 60
An Undocumented Structure 60
Towards a Solution 61
Summary 64
Further Reading 64
ii
Table of Contents
Chapter 4: Investigating the Nature of Files 67
What SHGetFileInfo() Can Do for You 68
How SHGetFileInfo() Works 68
Specifying the Input File 69
Using Wildcards with SHGetFileInfo() 70
The Display Name 72
The Sample Program 72
The Flags of the Function 76
Getting Information for a Given File Type 77
Shell Icon Size 78
Using a PIDL 79
Getting Attributes for a File 80
Creating the 'Hand-held' Folder Icon 81
Binary Format of Executables 85
SHGetFileInfo() Return Values 87
Summary 88
Further Reading 89
Chapter 5: Browsing for Folders 91
Choosing a Folder 91
A More Modern Approach 92
The Prototype of SHBrowseForFolder() 93
Using SHBrowseForFolder() 94
What the Function Returns 95
Getting the Folder Icon 95
Using a Callback Function 96
Events You Can Detect 97
Messages You Can Send 98
Customizing the User Interface 98
Removing the Context Help Button 98
Adding a 3D Border to the Status Text 99
Changing the Dialog Caption 100
Moving the Dialog Window 101
Animating the Status Label 101
Validating Manual Editing 101
Specifying the Initial Folder 103
Specifying the Root Node 103
Using a Directory as the Root 104
Putting it all Together 106
That Crazy Little Thing Called PIDL 110
Freeing PIDLs 110
How to Use PIDLs 111
Searching by Display Name 112
Building an Enumerator Function 116
iii
Table of Contents
The Callback Functions 122
The Sample Program 123
Searching by PIDL 124
Special Folders 125
System Support for Special Folders 125
Getting the Path to a Folder 127
Functions 127
Folder Settings 128
SHGetSettings() 128
Watch the File Extension 129
Make the Desktop More Active 130
How to Click a List View 130
Delete Confirmation 131
The Sample Program 131
Setting Preferences 132
Where are Preferences Stored? 132
Adding Custom Options to the Standard Dialog 133
When Custom Options Are Helpful 135
Summary 135
Further Reading 136
Chapter 6: The Shortest Path to Shortcuts 139
What are Shortcuts? 140
The Shortcut File Type 140
Creating Shortcuts 140
Using the IShellLink Interface 140
A Global Function for Shortcuts 142
Shell Scriptable Objects 143
Giving Shortcuts the Right Name 144
Deleting Shortcuts 144
Resolving Shortcuts 145
How Explorer Resolves Shortcuts 145
A Function for Resolving Shortcuts 145
Shortcuts and Special Folders 147
The Sample Program: Shortcut Manager 148
Selecting a Shortcut 148
Shell Drag-and-Drop 149
Displaying the Results 149
The Hotkey Common Control 151
Collecting Arguments for Creation 152
Giving Rules to the Hotkey 152
The Source Code 153
DoCreateShortcut() 153
DoResolveShortcut() 154
HandleFileDrop() 155
APP_DlgProc() 156
iv
Table of Contents
OnInitDialog() 157
Creating Shortcuts in System Folders 158
The SendTo Folder 159
The Recent Folder 160
Summary 160
Further Reading 160
Chapter 7: Shell Invaders 163
Notifying the Shell of Events 164
Notification Objects 164
Using Notification Objects 164
Putting it all Together 167
Explorer and Notification Objects 170
Towards a File System Monitoring Utility 171
SHChangeNotify() 171
Calling SHChangeNotify() 171
The Role of SHChangeNotify() 172
Using SHChangeNotify() 174
Invading the Shell's Memory Space 175
The Brute Force Approach 175
Why Hooks? 176
Invited into the Shell's Memory Space 182
SHLoadInProc() 183
A Minimal COM Object 183
How a COM Object is Made 184
The Role of DllGetClassObject() 184
The Role of DllCanUnloadNow() 185
Source Code for the COM Object 185
Registering the COM Object 186
Deregistering the Object 188
A Brand New Start Button 189
Getting the Button Handle 190
Replacing the Bitmap 191
Subclassing the Window 194
A New Menu 197
Creating Owner-Drawn Menus 198
Determining the Menu's Screen Position 199
Loading a New Menu 200
Collecting Menu Items Dynamically 201
Setting the Measurements 203
Drawing the Items 204
Executing Commands 208
Browser Helper Objects 209
Backward Compatibility 209
Activation Mechanism 210
Registration 210
v
Table of Contents
Structure of the COM Object 210
Communication with the Host 210
Usage 210
Registering Helper Objects 211
The IObjectWithSite Interface 211
Writing a Helper Object 211
An ATL COM Object 213
Helper Objects under Windows NT 217
Glossary of Techniques for Entering the Shell 217
Summary 218
Further Reading 218
Chapter 8: Program Executors 221
From WinExec() to CreateProcess() 222
A Comparison of WinExec() with CreateProcess() 222
Is CreateProcess() Manna from Heaven? 223
ShellExecute() 224
The Open Operation 225
The Explore Operation 226
The Print Operation 227
Printing to Ports 228
The Find Operation 228
A Frustrating Documentation Error 229
More Details of the Verbs 229
Verbs and File Handlers 229
Getting the Executable Name for a File 232
Flaws in FindExecutable() 233
Using Long File Names without Rules 234
ShellExecute() Tips and Tricks 236
Detecting the Default Browser 236
Connecting to a URL 237
Sending e-mail Messages 237
Printing Documents 237
Finding Files and Folders 238
ShellExecute() vs. CreateProcess() 238
Why You Should Use ShellExecute() to Run Programs 238
Extending ShellExecute() 239
ShellExecuteEx() 240
The Optional Members 241
Displaying a File's Properties Dialog 242
ShellExecuteEx() Return Values 243
Example: Program Executors 243
Multi-Monitor Support 245
Hooking on ShellExecute() 246
vi
Table of Contents
Registering an IShellExecuteHook Handler 246
The IShellExecuteHook Interface 247
Returning from the Hook 248
Writing an IShellExecuteHook Handler 248
Editing the Registry Script 250
How the Hook Works 251
Summary 252
Further Reading 252
Chapter 9: Icons and the Windows Taskbar 255
What You Should Know About Icons 256
Creating Icons 256
Creating and Modifying Icons Programmatically 257
Drawing Icons 258
Animated Icons 258
Extracting Icons from Files 258
What About LoadImage() and LoadIcon()? 260
Which is the Best Way? 261
Assigning Icons to Dialog Boxes 261
Browsing for Icons 262
A SHBrowseForIcon() Function 262
How to Call SHBrowseForIcon() 266
The Tray Notification Area 267
Putting Icons in the Tray Notification Area 267
Notifying Mouse Events 269
Writing Tray Applications 269
Pay Attention to the Context Menu 271
How Many Icons are in the Tray Notification Area? 273
Detecting When the Shell Restarts 273
Restarting the Windows Shell 274
The Layout of the Taskbar 275
When a Window Goes in the Taskbar 275
Toggling the Visibility of the Taskbar 276
Flashing a Window 276
The Windows Taskbar 277
Getting the Taskbar's State Programmatically 277
Hiding the Taskbar 282
The ITaskbarList Interface 282
What ITaskbarList Promises to Do 283
An IDL Definition for the Interface 283
ITaskbarList Sample Program 284
Taskbar-Window Communication 286
Setting up a Menu 287
Determining the Menu Position 289
Summary 291
vii
Table of Contents
Further Reading 291
Chapter 10: Windows Helper Libraries 293
The Versioning Epidemic 294
DLL Version Information 294
Version Number of a System DLL 295
Exposing the Version Number in your Own Functions 296
A More General Function 298
The Recycle Bin API 302
Structure of the Recycle Bin 302
Renaming Convention 303
The Recycle Bin View 304
Functions for Interacting with the Recycle Bin 304
Helper Libraries 305
The Registry Shell API 306
Table of Functions in the Registry Shell API 306
Manipulating Strings 307
Table of Functions for Manipulating Strings 307
Manipulating Path Strings 308
Table of Functions for Manipulating Path Strings 308
The Case for SHFormatDrive() 310
What the Function Does 310
SHFormatDrive() and Windows NT 311
A General Approach to Improving System Dialogs 311
Extending the Syntax of SHFormatDrive() 312
The Windows NT Dialog Box 313
An Automatic Function for Formatting Drives 314
Setting Volume Labels 315
Silent Formatting 315
Further NT Problems 316
The Sample Program 318
Summary 319
Further Reading 319
Chapter 11: Exploring the Shell 323
Explorer's Command Line 324
The /root Switch 325
Using Special Folders as the Root 325
What is rundll32.exe? 326
Functions Callable By rundll32.exe 326
What you can do with rundll32.exe 327
A RunDll() Function 328
Commonly Used Commands 330
The Explorer's Objects 331
viii
Table of Contents
The Control Panel 332
Developing Control Panel Applets 332
Running Control Panel Applets 335
RunDll32.exe and RunDll() Trade-offs 336
The Printers Folder 337
Invoking Printer Commands 337
What the Function Returns 338
Dial-Up Networking 338
Offline Browsing 339
Scheduled Tasks 339
Windows NT Support for Scheduling 339
The Scheduling Agent 339
Tasks and Triggers 339
My Briefcase 340
Scrap Objects 341
A New Shortcut Handler 341
The User Interface 342
The Old Functions 342
The New Functions 345
How to Replace the Windows Wizard 347
Editing the Registry 348
Summary 349
Further Reading 349
Chapter 12: Scriptable Shell Objects 353
The Best Language to Program the Shell 354
Undocumented Shell Features 354
The Shell Object Model 355
Methods of the Shell Object 357
BrowseForFolder() 358
ControlPanelItem() 359
Explore() 359
NameSpace() 359
Open() 359
Windows() 360
Attributes of the Shell Object 360
Invoking the Shell Object 360
Using Visual Basic 360
Using C++ 364
The Folder Object 366
More on Folder Object Methods 367
CopyHere() 367
GetDetailsOf() 367
Items() 368
MoveHere() 368
ix
Table of Contents
NewFolder() 368
ParseName() 368
The FolderItem Object 369
Invoking an Item's Verbs 369
The FolderItemVerbs Collection 370
The FolderItemVerb Object 370
Accessory Objects 371
The ShellUIHelper Object 371
Adding to Favorites 372
Putting it all Together 373
Summary 379
Further Reading 379
Chapter 13: The Windows Scripting Host 381
Windows Batch Files — At Last 382
What Can the WSH do for You? 382
Running Scripts at Startup 382
Structure of the WSH Environment 383
How to Get the Windows Scripting Host 383
What is the Host? 383
The Host Command Line 383
Shell Support for Script Files 384
The Scripting Engine 386
Registering New Scripting Engines 386
Command Line Arguments 387
The WSH Object Model 387
The WScript Object 387
The WshShell Object 389
Shortcuts and URL Shortcuts 390
The WshNetwork Object 390
Helper Objects 391
The WshArguments Object 392
The WshCollection Object 392
The WshEnvironment Object 392
The WshShortcut Object 392
The WshUrlShortcut Object 393
The WshSpecialFolders Object 393
Accessing the Registry 394
Supported Types 394
Deleting a Registry Entry 394
Reading from the Registry 395
Writing to the Registry 397
Doing More with the Registry 398
Scripting the Local File System 398
Accessing Existing Objects 400
x
Table of Contents
Handling Events with the WSH 400
Defining an Event Handler 400
Steps to Creating an Event Handler 401
Adding New Objects to the WSH 401
Arranging an ATL Automation Server 402
Defining the Programming Interface 402
Clipboard Support 403
Copying Text 403
Reading Text 403
Drive Formatting 404
Browsing for Icons 405
Registry Key Enumeration 407
Enumerating Keys 407
Enumerating Values 408
Using Enumerators 409
Hooking a Program's Execution 411
Hints for Improving the WSH 412
Adding User Interface Support 413
Creating dialogs 413
The alert() Dialog Box 414
Drag-and-Drop on WSH Files 414
Reusability within the WSH 414
Summary 415
Further Reading 416
Chapter 14: Designing a Shell-Integrated Application 419
Shell-Integrated Applications 420
Documents and the Shell 421
Basic Document Functions 421
The 'Send To' Command 422
Registered Document Types 423
Shell User Interface for Documents 424
Document-Specific Commands on the Context Menu 424
Shell Extensions for Documents 425
How Programs are Affected 425
MDI versus SDI 426
Creating New Documents 426
The New Menu 427
Creating New HTML Files 428
Other Features 429
Application Paths 429
Automatic Startup of Applications 430
Another RunOnce Key 431
The Run Key 432
The RunServices Keys 432
xi
Table of Contents
The Winlogon Key 433
Services in Windows 9x 433
Designing a Shell-Integrated Application 434
A Metafile Viewer 435
Windows Metafiles and Enhanced Metafiles 435
Displaying a Metafile 436
Printing and Converting a Metafile 438
Assembling the Viewer 441
Adapting the Application 443
The Importance of the Command Line 443
Why a Single Instance Application? 445
Dialog-Based Single-Instance Application 446
Adding Shell Support 447
Changing the Default Menu Item 450
Adding Context Menu Items for any File 450
Give a Folder a Custom Icon 451
Adding Recent Documents is Free 452
Drag-and-Drop Support 452
Customized Open Dialogs 453
Defining a New Template 453
New Dialog Features 455
Bookmarks to Frequently Used Paths 455
Icon and Tooltips for the Buttons 456
Tying the Code Together 457
Prevent the Renaming of Items 458
Tips for Preventing File Deletion 459
What is a Shell-integrated Application? 460
Summary 460
Further Reading 461
Chapter 15: Shell Extensions 463
Shell Extensions: Types and Tips 464
What are Shell Extensions? 464
Calling Shell Extensions 465
File Manager Add-ons 465
From File Manager Add-ons to Shell Extensions 465
How Explorer Calls Into Shell Extensions 466
Displaying a Context Menu 466
Types of Shell Extensions 467
Writing Shell Extensions 467
Using ATL 468
Our First Shell Extension 468
Adding Property Pages 468
Which Interfaces to Implement 468
Initialization of Shell Extensions 468
xii
Table of Contents
The IShellExtInit Interface 469
The IShellPropSheetExt Interface 472
Adding a New Property Page 473
Code for Initialize() 474
Code for AddPages() 475
Registering Shell Extensions 476
Testing Shell Extensions 478
Debugging under Windows NT 480
Unloading a Shell Extension 480
More on Property Page Shell Extensions 481
Modifying the Code to Support Multiple Selection 482
Context Menu 485
Implementing IContextMenu 485
Help Text for the New Item 485
A Behavior for the New Item 486
Adding a New Item 487
A Dependency List for Executables 489
Creating a Context Menu Extension 489
Getting an Executable's Dependency List 492
Registering the Extension 497
Adding a New Find Menu 498
Configuring the Registry 499
Finding the Running Processes 500
IContextMenu2 and IContextMenu3 500
Right-hand Drag & Drop 501
Registering Drag & Drop Handlers 502
Assigning Dynamic Icons 503
Different Icons for Different Color Depths 504
Initializing the IconHandler Extension 504
Retrieving the Icon 504
Details of the Example 506
Registering the Icon Handler 509
Monitoring Folders through ICopyHook 510
Implementing ICopyHook 511
What's ICopyHook's IID? 513
Logging the Operations 513
Registering a CopyHook Extension 514
Monitorable Objects 515
More on Copy Hooking 515
Dropping Data over a File 516
The DropHandler Extension 516
The IDropTarget Interface 516
Handling the Drop Event on TXT files 519
Adding Shell Support to Script Files 522
The Project and the Registration Script 523
Dropping Parameters over Script Files 523
xiii
Table of Contents
DataHandler Shell Extensions 525
The COM Interfaces Involved 526
A Shell Extension Developer's Handbook 526
File Viewers 527
Starting a Quick View 528
How a Quick Viewer Gets Called 529
Writing a Quick Viewer 529
Showing the File 529
Pinning 531
Writing and Registering a File Viewer 532
Summary 532
Further Reading 533
Chapter 16: Namespace Extensions 537
An Overview of Namespace Extensions 538
What Does Writing a Namespace Extension Mean? 539
The Inner Structure of Explorer 541
Namespace Extensions vs. Shell Extensions 541
Primary Interfaces 541
An Activation Timeline 542
The Folder Manager 542
Enumeration of Items 545
The Shell View 548
Additional Interfaces 556
Getting Pointers to Additional Interfaces 556
The Concept of Folders 558
Folder Attributes 559
Flavors of Namespace Extensions 560
Rooted Extensions 561
Non-rooted Extensions 561
Rooted vs. Non-rooted 561
When to use Which 562
Junction Points 563
Using a File Type 563
Using a Directory 564
What you can do with a Namespace Extension 566
Designing Our Namespace Extension 566
What's a Folder Here? 567
Designing a Custom PIDL 567
How to Build a Window Enumerator 567
Designing the View 567
Implementing Our Namespace Extension 568
Common Features of Registry View and Windows View 568
The Windows View Project 569
xiv
Table of Contents
The PIDL Manager Class 570
Creating a PIDL 571
Extracting Information from a PIDL 572
The Windows Enumerator 574
Getting the Next Items 577
The Folder Manager 578
Comparing Items 579
Folder Attributes 581
The Window View 583
Style of the List View 585
Sorting by Columns 588
Browsing for Windows 590
Giving it a User Interface 591
Menu Modifications 592
Displaying Help Text 594
Associating a Context Menu with Items 595
Code for a Better Context Menu 597
Associating an Icon with Items 598
Installing a Namespace Extension 599
A Node on the Desktop 601
Adding an InfoTip 602
Adding a Removal Message 603
Making a Folder Deletable 603
Additional Attributes for a Folder 604
Browsing a Custom Folder 604
Putting this Example to Work 605
Uninstalling the Sample 605
Summarizing Namespace Extensions 605
What's a Web View? 606
The Shell View ID 607
The Default View 607
New Functions in IShellView2 608
What's New in IPersistFolder2 609
How a Web View is Structured 609
Getting in Touch with the Classic View Object 610
The Template of a Web View 611
Firing Events 611
From Custom to Customized Folders 611
Folder Customization 612
The Default Template 613
The Desktop.ini File 613
Creating a New Template 616
Hosting Applications through Namespace Extensions 619
The URL Folder Example 620
Summary 620
xv