1: want to use PB program reads a file name, page number, time, what good method,
2: it is best to implement a task can trigger when reading,
CodePudding user response:
CodePudding user response:
Try to use the$PBExportHeader $uo_class_printer. Sru
$PBExportComments $about printer function
Forward
Global type uo_class_printer from nonvisualobject
End type
End forward
Type systemtime from structure
Uint wyear
Uint wmonth
Uint wdayofweek
Uint wday
Uint whour
Uint wminute
Uint wsecond
Uint wmillisecond
End type
Type job_info_1 from structure
Unsignedlong jobid
Unsignedlong pprintername
Unsignedlong pmachinename
Unsignedlong pusername
Unsignedlong pdocument
Unsignedlong pdatatype
Unsignedlong pstatus
Unsignedlong status
Unsignedlong priority
Unsignedlong position
Unsignedlong totalpages
Unsignedlong pagesprinted
Unsignedlong submitted
End type
Type printer_defaults from structure
String pdatatype
Unsignedlong pdevmode
Unsignedlong desiredaccess
End type
Global type uo_class_printer from nonvisualobject
End type
Global uo_class_printer uo_class_printer
The type as
The FUNCTION ulong OpenPrinter (ref string pPrinterName, ref ulong phPrinter, ref PRINTER_DEFAULTS pDefault) LIBRARY "winspool. DRV" ALIAS FOR "OpenPrinterA
"The Function ulong CopyMemory (ref JOB_INFO_1 destination, ref blob source, ulong length) library "kernel32. DLL" Alias for "RtlMoveMemory
"The Function ulong CopyMemory (ref SYSTEMTIME destination, ref blob source, ulong length) library "kernel32. DLL" Alias for "RtlMoveMemory
"The FUNCTION ulong EnumJobs (ulong hPrinter, ulong FirstJob, ulong NoJobs, ulong Level, ref blob Job, ulong cdBuf, ref ulong pcbNeeded, ref ulong pcReturned) LIBRARY "winspool. DRV" ALIAS FOR "EnumJobsA
"
End as
Forward as
The public function integer of_get_jobinf (long al_hprinter, ref long asa_jobid [], ref string asa_pprintername [], ref string asa_pmachinename [], ref string asa_pusername [], ref string asa_pdocument [], ref string asa_pdatatype [], ref string asa_pstatus [], ref long ala_status [], ref long ala_priority [], ref long ala_position [], ref long ala_totalpages [], ref long ala_pagesprinted [], ref datetime adta_submitted [])
The public function long of_openprinter (ref string as_printername)
End as
The public function integer of_get_jobinf (long al_hprinter, ref long asa_jobid [], ref string asa_pprintername [], ref string asa_pmachinename [], ref string asa_pusername [], ref string asa_pdocument [], ref string asa_pdatatype [], ref string asa_pstatus [], ref long ala_status [], ref long ala_priority [], ref long ala_position [], ref long ala_totalpages [], ref long ala_pagesprinted [], ref datetime adta_submitted []);/*
Function:
Pick up the print task status value
Parameters:
Al_hprinter: printer handles
Job_info_1 project: the structure of the store printer information (output)
The return value:
Returns the number of print tasks; Error return 1
*/
Constant int JOB_STATUS_PAUSED=1
Constant int JOB_STATUS_ERROR=2
Constant int JOB_STATUS_DELETING=4
Constant int JOB_STATUS_SPOOLING=8
Constant int JOB_STATUS_PRINTING=16
Constant int JOB_STATUS_OFFLINE=32
Constant int JOB_STATUS_PAPEROUT=64
Constant int JOB_STATUS_PRINTED=128
Constant ulong SYSTEMTIME_LEN=8 * 2
//because submitted is also a structure that is 13-1=12
Constant ulong JOB_INFO_1_LEN=12 * 4 + SYSTEMTIME_LEN
Ulong ll_Needed, ll_Returned
Job_info_1 lstr_inf//load the print task information
Systemtime lstr_systime//loading system time format (UTC)
Blob lbl_buf, lbl_temp
String ls_docname
Long nloop RTN, ll_size ll_status, ll_buf
The date ld_buf
Time lt_buf
String ls_buf
Ll_Size=1
SEG_GETJOB:
Lbl_buf=blob (Space (ll_size))
If EnumJobs (al_hprinter, 0, 65535, 1, lbl_buf, ll_size, ll_Needed, ll_Returned)=0 then
If ll_size & lt; Ll_Needed then
Ll_size=ll_Needed
Goto SEG_GETJOB
The else
The return - 1
End the if
End the if
For nloop=1 to long (ll_Returned)
//take a task state
Lbl_temp=BlobMid (lbl_buf, (nloop - 1) + 1) * JOB_INFO_1_LEN
If CopyMemory (lstr_inf lbl_temp, JOB_INFO_1_LEN)=0, then return 1
//take the task in time state
Lbl_temp=BlobMid (lbl_temp JOB_INFO_1_LEN - SYSTEMTIME_LEN + 1)
If CopyMemory (lstr_systime lbl_temp, SYSTEMTIME_LEN)=0, then return 1
Asa_jobid [nloop]=lstr_inf. Jobid
Asa_pprintername [nloop]=string (lstr_inf pprintername, "address")
Asa_pmachinename [nloop]=string (lstr_inf pmachinename, "address")
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull