Get a new network printer has several reports waiting for printing

zhaozj2021-02-11  253

When we want to print a report, if the printer is this machine's printer, of course, you will print out the report immediately. Anyway, the printer is only available for you! But if it is a large number of companies or businesses, many people often have to share a certain printer, and the printer is not necessarily placed on the place!

When you throw the report to the network printer, you must take a report because you don't see the printer, you must take a statement in the place where the printer is placed. At this time, you care about it is that the report is printed. If you haven't, then How many reports have not yet printed before your report?

Below this program allows you to know a few of the network printers still wait for the printed report? While your program is thrown out of the report, you can tell you User, and his report is in the first few!

Add the following declarations and modules in .bess files:

'Constants definitionPublic const cchdevicename = 32public const cchformname = 32public const printer_access_administer = & h4public constprinter_access_use = & h8

'Types DefinitionPublic Type DEVMODEdmDeviceName As String * CCHDEVICENAMEdmSpecVersion As IntegerdmDriverVersion As IntegerdmSize As IntegerdmDriverExtra As IntegerdmFields As LongdmOrientation As IntegerdmPaperSize As IntegerdmPaperLength As IntegerdmPaperWidth As IntegerdmScale As IntegerdmCopies As IntegerdmDefaultSource As IntegerdmPrintQuality As IntegerdmColor As IntegerdmDuplex As IntegerdmYResolution As IntegerdmTTOption As IntegerdmCollate As IntegerdmFormName As String * CCHFORMNAMEdmUnusedPadding As IntegerDMbitSperpel As Longdmpelswidth As Longdmpelsheight As LongdmdisplayFrags As LONGEEND TYPEFREQUENCY AS

Public Type Printer_DefaultspDataType As StringPdevmode As DevmodedesiredAnccess As Longend Type

'API DeclarationSpublic Declare Function OpenPrinter Lib "Winspool.drv" Alias ​​"openprintera" _ (Byval Pprintername As String, Phprinter As LONG, _PDEFAULT AS Printer_Defaults) AS Long

Public Declare Function EnumJobs Lib "winspool.drv" Alias ​​"EnumJobsA" _ (ByVal HPrinter As Long, ByVal FirstJob As Long, ByVal NoJobs As Long, _ByVal Level As Long, pJob As Byte, ByVal cdBuf As Long, _pcbNeeded As Long, pcReturned As longpublic declare function closehandle lib "kernel32" (Byval Hobject As long) As long

'Get the specified printer, the current number of Jobs (maximum of 128)' name of the printer can be a network path name mapping, for example: "// myserver / myprinter" Function GetPrinterQueue (PrinterName As String) As LongDim PrinterStruct As PRINTER_DEFAULTSDim HPrinter As Longdim Ret As Booleandim Jobstruct (0 to 127) AS BYTEDIM PCBNEEDED AS LONGDIM PCRETURNED AS Longdim Tempbyte as Byte

'Initial setting Printer structure PrinterStruct.pDatatype = vbNullStringPrinterStruct.pDevMode.dmSize = Len (PrinterStruct.pDevMode) PrinterStruct.DesiredAccess = PRINTER_ACCESS_USE' acquired printer Handleret = OpenPrinter (PrinterName, HPrinter, PrinterStruct) 'acquired printer active jobsret = EnumJobs (HPrinter, 0, 127, 1, TempByte, 0, pcbNeeded, pcReturned) If pcbNeeded = 0 ThenGetPrinterQueue = 0Elseret = EnumJobs (HPrinter, 0, 127, 1, JobStruct (0), pcbNeeded, pcbNeeded, pcReturned) GetPrinterQueue = pcReturnedEnd If 'Close the printer RET = CloseHandle (HPRINTER) End Function

'Put a Commandbutton in the form, the program code is as follows:

Private Sub Command1_Click () Test Preset Printer Queue (Printer.Devicename) MsgBox "& GetPrinterQueue (Printer.Devicename) &" Report ", 64," Message "end SUB

The above code from: the source code database (SourceDataBase) Current Version: 1.0.392 Author: Shawls profile: Http://Shawls.Yeah.Net E-Mail: ShawFile@163.Net QQ: 9181729

转载请注明原文地址:https://www.9cbs.com/read-4844.html

New Post(0)