Newsgroup: it.comp.lang.visual-basic
Titolo: api della stampante

Qualcuno sa se posso con API di WIN per la stampante vedere se ci sono code,
se qualche processo si interrotto, o se ci sono problemi...?
TIA
Marcello

se qualche processo si interrotto, o se ci sono problemi...?
su msdn ci sono due articoli con codice di esempio (c++).
HOWTO: Get the Status of a Printer and a Print Job 
Q160129
http://support.microsoft.com/support/kb/articles/Q160/1/29.asp
HOWTO: Retrieve Print Job Information 
Q228769
http://support.microsoft.com/support/kb/articles/Q228/7/69.ASP
su qualche hard disk ho il codice in vb, ma dovrei cercarlo, guarda un po'
se ti possono bastare.
ciao, hal

 wrote in message
9fsv82$5r0jr$1...@ID-56381.news.dfncis.de...


Vedrò gli articoli ma non vado d'accordo con C++.
Ok, per adesso guarda se ti puo' servire il codice riportato
sotto la firma.
Nota che non l'ho provato perche' qui non ho stampanti in linea.
(l' ho copiato da 
http://161.58.84.211/ref/e/enumjobs.html
, 
spero non se ne abbiano a male :)
Il codice e' di Paul Kuliniewicz  (
http://www.vbapi.com
).
hth, hal
====================================================
Parameters
hPrinter: A handle to the printer to enumerate the print jobs of. 
FirstJob: The zero-baded position in the print queue to begin print job enumeration from. To enumerate all jobs, of course set this to 0. To enumerate everything except the first job, set this to 1 (identifying the second print job), etc. 
NoJobs: The maximum number of print jobs to enumerate. 
Level: Identifies the format of the information placed into the array passed as pJob. If this is 1, the data is in the format of JOB_INFO_1 structures. If this is 2, the data is in the format of JOB_INFO_2 structures. 
pJob: An array which receives all the information about the print jobs retrieved by the function. The format of this data is specified in Level. The array must be large enough to receive all the data. If you are setting cbBuf to 0, this must also be 0. 
cbBuf: The size in bytes of the array passed as pJob. To determine how large the array must be, set this to 0. 
pcbNeeded: Receives the number of bytes of data copied into the array passed as pJob. If the function failed, this is the minimum size in bytes which the array passed as pJob must be. 
pcReturned: Receives the number of print jobs retrieved by the function. 
' This code is licensed according to the terms and conditions listed here.
' Display a little information about each print job in the
' queue for the default printer.  Note how both EnumPrinters and
' EnumJobs first copy the data into the arrays before placing
' the information into the desired structure.
Dim pi1 As PRINTER_INFO_1  ' holds a little information about the printer
Dim hPrinter As Long  ' handle to the default printer once it is opened
Dim arraybuf() As Long  ' resizable array used as a buffer
Dim jobinfo As JOB_INFO_2  ' holds detailed info about a print job
Dim needed As Long  ' receives space needed in the buffer array
Dim numitems As Long  ' receives the number of items returned
Dim lendivfour As Long  ' the size in Long-type units of the jobinfo structure
Dim c As Long  ' counter variable
Dim retval As Long  ' return value
' -- Get the name of the default printer. --
' Determine how much space is needed to get the printer information.
retval = EnumPrinters(PRINTER_ENUM_DEFAULT, "", 1, ByVal 0, 0, needed, numitems)
' Resize the array buffer to the needed size in bytes.
ReDim arraybuf(0 To needed / 4 - 1)  ' remember each element is 4 bytes
' Retrieve the information about the default printer.
retval = EnumPrinters(PRINTER_ENUM_DEFAULT, "", 1, arraybuf(0), needed, needed, numitems)
' Copy the printer name into the structure.  The rest is unnecessary.
pi1.pName = Space(lstrlen(arraybuf(2)))
retval = lstrcpy(pi1.pName, arraybuf(2))
' -- Obtain a handle to the default printer (using default configuration). --
retval = OpenPrinter(pi1.pName, hPrinter, ByVal CLng(0))
' -- Enumerate the default printer's print jobs currently queued. --
' Determine how much space is needed to get the print jobs' information.
retval = EnumJobs(hPrinter, 0, 100, 2, ByVal 0, 0, needed, numitems)
' Resize the array buffer to the needed size in bytes.
ReDim arraybuf(0 To needed / 4 - 1)  ' remember each element is 4 bytes
' Retrieve the information about the print jobs.
retval = EnumJobs(hPrinter, 0, 100, 2, arraybuf(0), needed, needed, numitems)
' Display the number of print jobs currently in the queue.
If numitems > 0 Then
  Debug.Print "There are"; numitems; "print jobs currently in the queue."
Else
  Debug.Print "No print jobs are currently in the queue."
End If
' For each print job, copy its data into the structure.  Then display selected
' information from the structure.  For brevity, this example copies only a
' few of the data members into the structure.
lendivfour = Len(jobinfo) / 4  ' this is the number of elements for each structure in the array
For c = 0 To numitems - 1  ' loop through each item
  ' Copy selected information into the structure: the job ID number, the
  ' name of the user who printed it, the total number of pages, and
  ' the time it was added into the queue.
  jobinfo.JobID = arraybuf(lendivfour * c)  ' the first element of the array chunk
  jobinfo.pUserName = Space(lstrlen(arraybuf(lendivfour * c + 3)))  ' fourth element
  retval = lstrcpy(jobinfo.pUserName, arraybuf(lendivfour * c + 3))
  jobinfo.TotalPages = arraybuf(lendivfour * c + 18)  ' nineteenth element
  CopyMemory jobinfo.Submitted, arraybuf(lendivfour * c + 20), Len(jobinfo.Submitted)  ' twenty-first element
 
  ' Display the copied information.
  Debug.Print "Job ID number:"; jobinfo.JobID
  Debug.Print "Printed by user: "; jobinfo.pUserName
  Debug.Print "Number of pages:"; jobinfo.TotalPages
  Debug.Print "Placed in queue on: ";
  ' (display the date and time stored in jobinfo.Submitted)
  Debug.Print jobinfo.Submitted.wMonth; "-"; jobinfo.Submitted.wDay; "-"; jobinfo.Submitted.wYear; " ";
  Debug.Print jobinfo.Submitted.wHour; ":"; jobinfo.Submitted.wMinute; ":"; jobinfo.Submitted.wSecond; " GMT"
Next c
' Close the printer handle now that it is no longer needed.
retval = ClosePrinter(hPrinter)

 wrote in message
9ftt82$66d4c$1...@ID-56381.news.dfncis.de...


 wrote in message
9ftt82$66d4c$1...@ID-56381.news.dfncis.de...
