NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
ASP.NET Authentication
ASP.NET Data Access
ASP.NET Page Events
.NET Data Types
.NET E-mail
.NET Functions
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Controls
ASP.NET Features
ASP.NET Master Pages
ASP.NET Security
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
HTML Tips
IIS
Object-Oriented Programming
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

Visual Basic 6 Win32 API Tutorial

Written by Eric Smith, Northstar Computer Systems

Written by Jason Bock
Published by Wrox Press

</span> <span class="subheading"> Table of Contents </span> <span class="text"> <ol>
  • API Fundamentals
  • API Pitfalls and the Encryption Program
  • Kernel32 Calls
  • User32 Calls
  • GDI32 Calls
  • API Calls Outside of Win32
  • Callbacks and the AddressOf Operator
  • COM Components </ol>

    The book also has these four appendices:

    <ol type="A">
  • Data Type Summary
  • Hungarian Notation
  • That Thing Called COM
  • Summary of API Declarations </ol> </span> <span class="subheading">Our Review</span> <span class="text">

    Visual Basic is an ideal language for beginning and intermediate programmers, since it hides so much of the Windows internals from the developer. However, this has a downside, as well. Many of the helpful functions common to other Windows applications are not exposed through Visual Basic procedures or functions. Some of the functions are embedded into OCXs, such as the Common Dialog control; however, OCXs take more system resources, especially if they are used repeatedly.

    Jason Bock's book is designed to show you how to exploit the power of the Windows API to get to some of those functions can't use right from Visual Basic. The book also avoids trying to be a reference; instead, it shows you some of the key API calls and where to find more.

    The first chapter starts out with a good introduction to how API calls fit into the Windows architecture. There is a good explanation of how DLLs are loaded into VB as API calls are used. It also shows how to use the API viewer, an important tool in the war to find hidden features. He also covers the so-called "undocumented API calls" that Microsoft is always being accused of using to beat the competition. Well, they are undocumented, but they're not exactly secret. The author debunks this myth by showing how to find these calls.

    The next chapter goes through some of the traps of using API calls, including incorrect declarations and data types, using the correct buffer sizes, and more. This is a must-read for any new (or even experienced) programmers who don't use the API every day. Some of these traps will cause VB to crash and take your unsaved work along with it.

    Chapter 3 covers the Kernel32 library, which is responsible for memory management, process control, multithreading, and file operations. The author has an excellent example of how to create an application that is able to manipulate files and encrypt them. The author also shows how, for speed alone, doing the same functions with native VB functions is actually faster. He does mention that the methods would need to be compared in more ways than just speed, but it is an interesting point that more of the API-only VB programmers could take to heart. Most of the file API calls are covered in this chapter; however, there isn't any coverage of the other types of functions in the Kernel32 library. It would have been nice to see some examples about threading or process control, since this question is a common one among VB programmers wanting to improve performance in their applications.

    The next chapter covers User32.DLL, which is responsible for windows, menus, and controls. User32 is used extensively behind the scenes by Visual Basic to create the widgets you draw in the environment. There are some good examples that span the library's functions in this chapter. There is an example of how to manipulate the built-in TreeView control to provide backgrounds, font formatting, and so on. There is also a discussion of the MessageBox API call, which is similar to the MsgBox function in VB. He also shows how to add images to menus, which is another common question.

    Chapter 5 covers graphics calls in the GDI32 library. If you have heavy graphics in your application and aren't using DirectX, you will come to know and love these calls. This is really where the performance improvements are versus Visual Basic native calls. The author provides numerous examples of the performance increases, as well as how to do some useful things with these somewhat more obscure calls.

    Chapter 6 picks up a major topic left out by the other well-known API text on the market: API calls outside of the three libraries covered earlier. This is where you find the really cool stuff, but it's not documented anywhere except MSDN, and you have to know how to combine certain API calls to get the desired result. This chapter is probably the most useful in the whole book, since the examples are common ones that most developers could come up with a use for. For instance, there is an excellent example on how the Windows shell takes care of file operations. The chapter also covers multimedia functions and some other functions that provide system information. It would have been nice to see a more complete list, but the author does provide the clues as to where to find more.

    Chapters 7 and 8 go hand-in-hand in covering advanced operations such as callbacks and subclassing. These are features that can have disasterous (read: blue screen of death) results if done improperly. However, the author provides a good explanation of how to use these features to make your code easier to deploy, as in the examples provided about COM components. Subclassing allows you to make minor changes and preserve all of the original functionality without having to reimplement it all.

    </span> <span class="subheading">The Bottom Line</span> <span class="text">

    If you've ever been stumped by the mysteries of the Windows API and all those functions you knew existed but could never find, this is a book for you. While it isn't good as a reference guide, beg, borrow, or steal a copy of the MSDN library and you have all the reference you need, especially when you know how to find the information you need as an expert API programmer.

    Keywords: [ Book Reviews ]

    Publication Date: 5/28/1999