Desaware Home
Products    Purchase    Publishing    Articles   Support    Company    Contact    
Licensing System
Professional Services
Universal .NET
Universal COM
.NET Books
COM Books
Visual Basic Programmer's Guide to the Win32 API
Introduction
Contents
Updates
Edition History
Exploring VB6 (series)
Developing COM/ActiveX Components with VB6: A Guide to the Perplexed
Introduction
Outline
What's New from the VB 5.0 edition
Updates
Win32 API Puzzle Book and Tutorial
Introduction
Chapter Outline
Sample Puzzle
Updates
NT Security Programming with Visual Basic 6
Updates
Visual Basic Programmer's Guide to the Windows 16 bit API
Other Books

bluebar
Contact Desaware and order today

bluebar
Sign up for Desaware's Newsletter for the latest news and tech tips.

Note: This page describes a legacy product or book. The page is available for archival purposes and as a courtesy to those who have linked to it, but is no longer being updated or maintained.
amazon

Visual Basic Programmer's Guide to the Win32 API
$47.99 [Print]

Updates and Corrections

Book Cover
The classic guide to Win32 API programming from VB6

Any book of 1500+ pages is bound to have some errors. The information here applies to various printings of the the latest edition of the book.

Common Errors

If during installation you receive a message indicating that a file ex20a.vbw cannot be opened, you need an updated setup program.

If you are receiving "File Not Found" errors, or one of the sample applications from the book are hanging with an odd flashing that can't be stopped, you may have a corrupt version of the file apigid32.dll (2nd printing, VB5 edition).

What about VB6? This book keeps referring to VB5!

ListAPI won't register as an add-in when run from the CD-ROM

If you are finding strange characters in program listings, your copy may be suffering from a printer font substitution error (2nd printing, VB5 edition).

Other Changes

Chapter 1

Table 1.1 – After the Windows 95 paragraph add:
All references to Windows 95 in this book include Windows 98 as well.

Chapter 4

In Listing 4.3, the last line of the Form_Load command:
Replace
file1.ListIndex = 0 with
If File1.ListCount>0 Then File1.ListIndex = 0

Chapter 6

SysInfo sample program.
In the Keycheck_KeyDown event, add the following line right before the end of the subroutine:
KeyCode = 0
This change allows the Del key to show up correctly.
Figure 6.1, 3rd box on the left.
The Visual Basic event referred to is KeyPress, not KeyPressed.
Chapter 6 Function Reference
SystemParametersInfo Function
When using the SPI_GETANIMATION option, uParam must be the size of the ANIMATIONINFO structure.

Chapter 7

In the final paragraph of the "Clipping" section, SetWindowRng should be SetWindowRgn.

Chapter 9

At the end of the section titled "Using Raster-Ops", the sentence refers to Appendix G for a list of raster operations. This should be Appendix E.

Chapter 11

DT_ENDELLIPSES should be DT_END_ELLIPSES
DT_PATHELLIPSES should be DT_PATH_ELLIPSES

Chapter 12

In listing 12.1 and listing 12.3, the dmUnusedPadding field of the DEVMODE structure is now defined as dmLogPixels. The dmBitsPerPel field should be defined as a Long. In Table 12.4 the dmUnusedPadding field is defined as the number of logical pixels per inch on display devices.
In Listing 12.4 The PrintBitmap function in the PicPrint sample application does not calculate the correct buffer size. The correct code is as follows:

Select Case bi.bmiHeader.biBitCount
   Case 1
   bufsize& = Int((bufsize& + 7) / 8)
   Case 4
   bufsize& = Int((bufsize& + 1) / 2)
   Case 24
   bufsize& = bufsize& * 3
   End Select
   ' And make sure it aligns on a long boundary
   bufsize& = (Int((bufsize& + 3) / 4)) * 4

Note that as a result of this bug, the buffer may be larger than necessary. However, in this particular example, having too large a buffer does no harm.
pSepFile in the PRINTER_INFO_2 structure in listing 12.8 should be declared as Long.

Chapter 12 Function Reference

All references to spoolss.dll should be winspool.drv
Code and api32.txt is correct.
AddJob function:
The Path field in the ADDJOB_INFO_1 structure should be a Long (pointer to an ANSI string).
AddMonitor function
All of the MONITOR_INFO_2 structure fields should be Long (pointers to ANSI strings) instead of String.
AddPrintProvidor function
All of the PROVIDOR_INFO_1 structure fields should be Long (pointers to ANSI strings) instead of String. The structure is PROVIDOR_INFO_1 instead of PROVIDER_INFO_1.

Chapter 13 Function Reference

RegDeleteKey function:
Under Windows NT, the key will NOT be deleted if subkeys exist.
RegEnumValue and RegQueryInfoKey functions.
The lpReserved parameter should be declared ByVal

Chapter 14 Function Reference

FindFirstChangeNotification Function
Comment section, FileCloseChangeNotification should be FindCloseChangeNotification.

Chapter 15

Organization of Data In Structures
Add the following sentence to the end of the third paragraph in this section:
"Alternatively, you can use the undocumented VarPtr function to obtain the address of the structure.Normally I do not recommend using undocumented functions, but this one has appeared so often in sample code that it is unlikely that Microsoft will remove it in future versions of Visual Basic".
2nd bullet in list in this same section:
Inside Visual Basic: Structures use natural boundary alignment, and fixed length strings take two bytes per character (see Figure 15.5)
The sample code has been changed. It is now:

Type mytype
   A As Byte
   B As Long
   End Type

This structure takes 8 bytes while stored within Visual Basic, 5 bytes in a disk file (single byte packing) and will be passed to a DLL as 8 bytes (variable B will be aligned to its natural boundary of 4).
A much more thorough discussion of alignment issues can be found in my new book "Dan Appleman's Win32 API Puzzle Book and Tutorials for Visual Basic Programmers".

Chapter 16

MDIPaint example: Refer to the CD-ROM for correct code for the version of Visual Basic that you are using. The code in the book is representative, but does vary due to changes in the behavior of VB over the versions.

Chapter 16 Function Reference

BroadcastSystemMessage function:
The constants for the pdw parameter should have the prefix BSM_ instead of BSF_. The BSF_NETDRIVERS constant should be BSM_NETDRIVER.

Chapter 18

The VB Declaration
Const CB_SETDROPPEDCONTROLRECT = &H160
should be
Const CB_SETDROPPEDWIDTH = &H160
Parameter wParam should be "The width of the drop-down list box in pixels"

Chapter 23

Type libraries that currently have char parameters should have all parameters replaced by CHAR (unsigned char).

Appendix A

agCopyData, agCopyDataBynum
The RtlMoveMemory API function, declared in kernel32.dll can also be used to perform memory copies. If you use this function note that the source and destination parameters are reversed from those of the agCopyData function.
agGetAddressForObject and variations
Visual Basic supports several undocumented functions that can be used to perform similar and in some cases identical operations to that provided by these functions.
VarPtr(anyparam) – Returns the address of the parameter as stored in Visual Basic's memory space.
StrPtr(stringparam) – Returns a pointer to the Unicode string as stored in Visual Basic's memory space.
Normally I would not recommend using undocumented functions, but Microsoft has used these so extensively in their sample code that it is unlikely that will be removed in future versions.

Appendix B

The correct declaration for the TIME_ZONE_INFORMATION structure is as follows.

Type TIME_ZONE_INFORMATION
   Bias As Long
   StandardName(31) As Integer
   StandardDate As SYSTEMTIME
   StandardBias As Long
   DaylightName(31) As Integer
   DaylightDate As SYSTEMTIME
   DaylightBias As Long
End Type

In the PRINTER_INFO_2 structure, the pSetFile field should be declared As Long.
In the ADDJOB_INFO_1 structure, the Path field shoud be declared As Long
All of the MONITOR_INFO_2 structure fields should be Long (pointers to ANSI strings) instead of String.
All of the PROVIDOR_INFO_1 structure fields should be Long (pointers to ANSI strings) instead of String.

Books
What about updates for Windows 2000 and XP?
 
Products    Purchase    Articles    Support    Company    Contact
Copyright© 2012 Desaware, Inc. All Rights Reserved.    Privacy Policy