FIX: Printers Collection May Not Contain All Printers in the Printers Folder (253612)
The information in this article applies to:
- Microsoft Visual Basic Control Creation Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
This article was previously published under Q253612 SYMPTOMS
With Visual Basic 5.0, when you are listing or searching for printers in the Printers collection, you may find that the Printers collection does not contain all the printers in the printers folder.
CAUSE
Visual Basic 5.0 uses the GetProfileString API function to obtain the list of printers. One parameter of GetProfileString is a memory buffer that is allocated to receive the results of the function call. This buffer is then filled in with the list of printers by the operating system (OS). The correct procedure is to first determine how large a buffer is needed and then to supply a buffer of that size. However, Visual Basic 5.0 always allocates a buffer of 1024 bytes. Therefore, if all of the names of all the of the printers shown in the printers folder total more than 1024 characters (including a null character at the end of each printer name), then the Printers collection is missing some printers.
RESOLUTION
The workaround is to call GetProfileString in your Visual Basic code to obtain a separate set of printer names.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This problem was corrected in Visual Basic 6.0.
REFERENCESFor additional information, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
266767 HOWTO: Set Which Printer is the System Default Printer
167735 FIX: Setting Printer to Item in the Printers Collection Fails
Modification Type: | Major | Last Reviewed: | 12/12/2003 |
---|
Keywords: | kbAPI kbBug kbfix kbprint kbVBp600fix KB253612 |
---|
|