Starting Page

only for RuBoard - do not distribute or recompile
click for table of contents

view annotations for this book

Table of Contents
Full Description
About the Author
Reader reviews

Visual Basic Shell Programming

J.P. Hamilton
Publisher: O'Reilly
First Edition July 2000
ISBN: 1-56592-670-6, 392 pages

start reading

Visual Basic Shell Programming ventures where none have gone before by showing how to develop shell extensions that more closely integrate an application with the Windows shell, while at the same time providing an advanced tutorial-style treatment of COM programming with Visual Basic. Each major type of shell extension gets attention, including customized context menu handlers, per instance icons, and customized property sheets.

only for RuBoard - do not distribute or recompile
only for RuBoard - do not distribute or recompile

Visual Basic Shell Programming

Copyright 2000 O'Reilly & Associates, Inc. All rights reserved.

Printed in the United States of America.

Published by O'Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472.

Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. The association between the image of a globigerina and Visual Basic shell programming is a trademark of O'Reilly & Associates, Inc.

MSDN is a trademark and ActiveX, IntelliSense, Microsoft, Visual Basic, Visual C++, Visual Studio, Win32, Windows, and Windows NT are registered trademarks of Microsoft Corporation.

While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.

only for RuBoard - do not distribute or recompile
only for RuBoard - do not distribute or recompile


Some friends and I were talking a few years back about computer books and bookstores in general. At the time, it seemed to us like no one was writing any books for people who already knew how to program. Every book on the shelf was a 900-page behemoth whose first few chapters told you how to turn on your computer, why the particular language was so great, and so on. The last eight chapters were always reference. We were convinced that if you took any one of these two-ton masterpieces and ripped out the irrelevant information, or information that could be found in the documentation, at best you would be left with about 200 pages of pertinence. That was our theory, anyway.

We decided it would be really great if someone would write a book that was skinny . These skinny books would contain the juiciest tidbits of programming informationthe ripest fruits from the tree of coding knowledge. Anything superfluous would be hacked away and left by the wayside. The skinny book would assume that you already knew why you were using a particular programming language. Therefore, it could forego the first three chapters found in most of the other books. It would be exciting to read cover to cover, because there would be something for everyone in each chapter. And last, but not least, it would serve as a reference that you could come back to again and again.

Now, there are a few such skinny books that I can think of off the top of my head. The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie (Prentice Hall) is one of my all-time favorites. Another is Effective C++ by Scott Meyers (Addison-Wesley). I've had both of these books for years, and they still hold a proud place on my bookshelf . They are skinny in the true sense of the word! I say this to prove that such books do exist.

So, what does all this talk about the inherent properties of skinniness mean? Well, I have to say it. The first motivation for writing this book was that I, too, wanted to write a skinny book. But not so fast . . . I am not saying that I place myself in the leagues of the aforementioned authors. You know, and I know, that that would be nothing short of blasphemy. So, make no mistakeI am an everyday programmer, just like you. All I wanted to do was to write a book that would be a good read, cover to cover: a book with good projects and an interesting topic. Really, my true goal was to write a book that I would buy myself . I hope I have done that.

I picked the shell for the topic of the book because, first and foremost, I thought it was really cool. I read an article on browser helper objects (see Chapter 12) by Scott Roberts in the May 1998 issue of Microsoft Interactive Developer . My first thought was, "I wonder if I could pull that off in VB?" (It seems I am always trying to "pull something off" in VB.) Well, I pulled it off. After that I just couldn't get enough of the shell. I wrote a band object (see Chapter 13) and then a context menu handler (see Chapter 4). In fact, most of the code for this book was written before I had even started the book.

As I was writing all this code, I realized something. I was working with some really interesting, advanced VB code. I was using pointers like nobody's business, rewriting system-level interfaces, and working with parts of COM that VB tries to hide away. In fact, I learned quite a bit about COM that VB didn't really want me to know. Topics of interest seemed to lead in unexpected directions. For instance, when I was doing the code for Chapter 11, I learned how to link lists in VB. That's when I thought to myself that this would make a really great book.

The material in this book pushes the perceived limits of what you can do with Visual Basic. Visual Basic offers a powerful development environment for virtually all types of applications, components , and tools. Yet, much of the time, all that we hear about are Visual Basic's limitationswhat you can't do. Each of these "can'ts" is used to prove the inferiority of Visual Basic and the superiority of the critic's favorite development environment or programming language. For instance, Visual Basic is seen as grossly inferior because it can't be used to create standard Windows dynamic link libraries (a contention , by the way, that is completely untrue). Also, how many times have you heard a "real" programmer complain about the absence of pointers in Visual Basic? (This charge, by the way, is also untrue.) Similarly, Visual Basic's strength as an application development package is turned into a weakness by its critics ; they argue that, while you can create applications quickly, these applications can't be tightly integrated with the Windows shell, since shell extensions can only be written in C++. Along with most Visual Basic programmers, I accepted that contention for a long time; this book, however, shows that limitation to be false and, in the process, implicitly shows that Visual Basic is a great tool for developing COM components of all kinds.

But I'm not going to lie to you. In order to accomplish some of the things we need to accomplish in this book, we have to take some very, very sneaky steps. But in my opinion, that's what makes VB so much fun. In one sense, this book is for the "hacker," the person who likes to get under the hood and explore the dark catacombs beneath the language. In another sense (hopefully), this book is a testament to just how flexible Visual Basic can be.

So, with that said, I have not tried to write a literary masterpiece. I just wanted to write a really neat book. I hope you enjoy it.

only for RuBoard - do not distribute or recompile