Microsoft KB Archive/201714

{|
 * width="100%"|

PRB: PRINTER_INFO_2 Incorrectly Defined in Visual Basic API Text Viewer

 * }

Q201714

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API)

-

SYMPTOMS
When you are using Win32 API functions that accept PRINTER_INFO_2 structures from Visual Basic, the API calls fail.

CAUSE
The Visual Basic API Text Viewer incorrectly defines two of the fields in the PRINTER_INFO_2 structure. Both the LPDEVMODE and the PSECURITY_DESCRIPTOR fields should be declared as Long rather than with their full structure definitions.

RESOLUTION
The following is the proper declaration of a PRINTER_INFO_2 structure in Visual Basic:

Public Type PRINTER_INFO_2

pServerName As String pPrinterName As String pShareName As String pPortName As String pDriverName As String pComment As String pLocation As String pDevMode As Long             ' LPDEVMODE pSepFile As String pPrintProcessor As String pDatatype As String pParameters As String pSecurityDescriptor As Long  ' PSECURITY_DESCRIPTOR Attributes As Long Priority As Long DefaultPriority As Long StartTime As Long UntilTime As Long Status As Long cJobs As Long AveragePPM As Long

End Type For most uses, both pDevMode and pSecurityDescriptor should be assigned a value of 0 (zero) to indicate that they are not being used.

MORE INFORMATION
Note that if these two fields are declared as Longs, they must be assigned the value 0 (zero) to indicate that they are NULL pointers.

For example, the new declaration for the PRINTER_INFO_2 structure would appear as:

Public Type PRINTER_INFO_2

pServerName As String pPrinterName As String pShareName As String pPortName As String pDriverName As String pComment As String pLocation As String pDevMode As Long pSepFile As String pPrintProcessor As String pDatatype As String pParameters As String pSecurityDescriptor As Long Attributes As Long Priority As Long DefaultPriority As Long StartTime As Long UntilTime As Long Status As Long cJobs As Long AveragePPM As Long

End Type Note that the same problem also affects the PSECURITY_DESCRIPTOR field of the PRINTER_INFO_3 structure.

Additional query words:

Keywords : kbGDI kbSDKPlatform kbSDKWin32 kbDSupport kbGrpDSGDI

Issue type : kbprb

Technology : kbAudDeveloper kbWin32sSearch kbWin32API