This book is for intermediate and advanced Visual Basic programmers who want to learn about COM. Many programmers create distributed applications using Microsoft Transaction Server (MTS) and Microsoft Message Queue (MSMQ), and many of them want to use Visual Basic instead of C++. These programmers need to understand how COM ties everything together. They also need to know how to create components that are both efficient and extensible.
This book is also for programmers who are interested in the interoperability between Visual Basic and C++ and who need to make Visual Basic components and C++ components talk to one another. I have provided C++/COM programmers with enough information about the way Visual Basic deals with COM to allow them to peacefully coexist in an environment with Visual Basic programmers.
From the time Microsoft engineers started working on the ideas behind COM in 1988 until COM first shipped in a product in 1993, COM went through quite an evolution. In this book, I'll trace this evolution and describe key decisions that the COM architects made along the way. You'll see that many low-level details, such as the way C++ compilers work and the way the remote procedure call (RPC) transport moves packets across the network, have a significant impact on the way you create distributed applications with Visual Basic. To understand why COM was designed the way it was, you must look at many of these details and think long and hard about them. These details are essential for readers who are interested in Visual Basic/C++ interoperability as well as those who care only about Visual Basic but still want to create distributed applications that are efficient and extensible.
Many Visual Basic programmers don't have the motivation or aptitude to learn about COM at this level. Visual Basic can extend a modest amount of COM functionality to these programmers without their needing any knowledge of the underlying technology, but they won't be able to create large information systems with MTS and MSMQ. This book is most definitely not for them.
I'll assume that you have some background with object-oriented programming and creating applications that use classes. It doesn't matter if you learned about classes using Visual Basic, C++, or Java. It's just important that you understand why you would design a class using encapsulation and that you understand the relationship between a class and an object.
Most readers of this book will have some background in database programming. It's hard to imagine that an intermediate Visual Basic programmer could have gotten by without being involved in at least one database-oriented application. When I describe writing transactions for MTS objects, I'll assume that you have a moderate comfort level with ActiveX Data Objects (ADO) and writing SQL statements. If you don't have this background, you should acquire it on your own. The ADO code and the SQL presented in this book are not overly complicated. For those of you who already know Data Access Objects (DAO) or Remote Data Objects (RDO), the online help for ADO will probably be all you need. Those of you who need additional help can find many other excellent resources on these topics.
It's helpful but not essential that you have some background in computer science or a low-level language such as C. It would be impossible for me to tell you about COM without talking about things such as pointers, memory addresses, stack frames, and threads. If you don't have this background, please take the time to contemplate what's going on at a lower level. Occasionally your temples might begin to throb. But the time and effort you invest will be more than worthwhile.
The CD included with this book contains the source code for several Visual Basic applications. These applications contain working examples of the code I use throughout this book. As a Visual Basic programmer, I've always felt that my understanding was boosted by hitting the F5 key and single-stepping through an application line by line. I'd like you to have the same opportunity. The file Samples.htm will give you a synopsis of all the applications and what they do.
The Setup directory on the CD contains the files and instructions for setting up the SQL Server database that you need to run the Market application. The Setup.htm file can walk you though the steps. Any other applications that have additional setup instructions will have a Setup.htm file in their directory. I hope you find these sample applications valuable.
In my work as an instructor and a writer, I'm continually improving and creating new Visual Basic applications that relate to COM and MTS programming. You're free to download the most recent collection of samples from my Web site, http://www.sublimnl.com. At this site, you'll also find other information relating to this book, including a listing of any bugs and inaccuracies. If you'd like to send me some feedback, mail it to me at firstname.lastname@example.org. I certainly hope you enjoy this book.