Bosna i Hercegovina



#16 13.12.2010-13:21
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,451


Subject: Re: Poruka o završetku printanja, dali može?
Sve si dobro napravio stim sto nisi sve procedure kopirao u modul.
Kopirao si samo deklaraciju.
Kopiraj sve i pokreni proceduru 'UpisST()'

Dobit ces u tabeli sve instalisane printere.
Pozdrav
↑  ↓

#17 13.12.2010-14:27
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Re: Poruka o završetku printanja, dali može?
Popravio sam to i pokrenuo proceduru, međuti nisu mi se upisali svi štampaći u tablicu. Nedostaju mi dva i među njima baš taj na koji šaljem izvještaje.

Epson DFX-8000

Ikona prilozene slike:
Stampaci.jpg
Tip fajla: Informacije o fajlu: jpg jpg
Preuzimanja: 55
Veličina: 152.40 KB
Veličina slike: 905 x 915 Pixels


Pozdrav
↑  ↓

#18 13.12.2010-15:08
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,451


Subject: Re: Poruka o završetku printanja, dali može?
Povecaj polje putanja na 255 karaktera pa probaj ponovo?.
Pozdrav
↑  ↓

#19 14.12.2010-11:11
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Re: Poruka o završetku printanja, dali može?
Napravio sam to i sada mi je procedura napunila tablicu sa podacima o printerima koji su dostupni sa kompjutera.
Što dalje

Prilozi:
Informacije o fajlu: rar  Printeri.rar
Preuzimanja: 58
Veličina: 15.99 KB


Pozdrav
↑  ↓

#20 14.12.2010-11:44
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,451


Subject: Re: Poruka o završetku printanja, dali može?
Eh veceras cu ti pokusati odraditi drugi dio.
Vjerovatno jos ovoliko koda kao ovo.
To je zuaseban modul i mozes ga negdje ostaviti moze ti trebati.
Pozdrav
↑  ↓

#21 14.12.2010-21:38
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,451


Subject: Re: Poruka o završetku printanja, dali može?
Ovaj Kod prekopiraj u drugi modul.

DownloadIzvorni kod (Visual Basic):
  1. Public Declare Function lstrcpy Lib "kernel32" _
  2.    Alias "lstrcpyA" _
  3.    (ByVal lpString1 As String, _
  4.    ByVal lpString2 As String) _
  5.    As Long
  6.  
  7. Public Declare Function OpenPrinter Lib "winspool.drv" _
  8.    Alias "OpenPrinterA" _
  9.    (ByVal pPrinterName As String, _
  10.    phPrinter As Long, _
  11.    pDefault As PRINTER_DEFAULTS) _
  12.    As Long
  13.  
  14. Public Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" _
  15.    (ByVal hPrinter As Long, _
  16.    ByVal Level As Long, _
  17.    pPrinter As Byte, _
  18.    ByVal cbBuf As Long, _
  19.    pcbNeeded As Long) _
  20.    As Long
  21.  
  22. Public Declare Function ClosePrinter Lib "winspool.drv" _
  23.    (ByVal hPrinter As Long) _
  24.    As Long
  25.  
  26. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
  27.    (Destination As Any, _
  28.    Source As Any, _
  29.    ByVal Length As Long)
  30.  
  31. Public Declare Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" _
  32.    (ByVal hPrinter As Long, _
  33.    ByVal FirstJob As Long, _
  34.    ByVal NoJobs As Long, _
  35.    ByVal Level As Long, _
  36.    pJob As Byte, _
  37.    ByVal cdBuf As Long, _
  38.    pcbNeeded As Long, _
  39.    pcReturned As Long) _
  40.    As Long
  41.    
  42. ' constants for PRINTER_DEFAULTS structure
  43. Public Const PRINTER_ACCESS_USE = &H8
  44. Public Const PRINTER_ACCESS_ADMINISTER = &H4
  45.  
  46. ' constants for DEVMODE structure
  47. Public Const CCHDEVICENAME = 32
  48. Public Const CCHFORMNAME = 32
  49.  
  50. Public Type PRINTER_DEFAULTS
  51.    pDatatype As String
  52.    pDevMode As Long
  53.    DesiredAccess As Long
  54. End Type
  55.  
  56. Public Type DEVMODE
  57.    dmDeviceName As String * CCHDEVICENAME
  58.    dmSpecVersion As Integer
  59.    dmDriverVersion As Integer
  60.    dmSize As Integer
  61.    dmDriverExtra As Integer
  62.    dmFields As Long
  63.    dmOrientation As Integer
  64.    dmPaperSize As Integer
  65.    dmPaperLength As Integer
  66.    dmPaperWidth As Integer
  67.    dmScale As Integer
  68.    dmCopies As Integer
  69.    dmDefaultSource As Integer
  70.    dmPrintQuality As Integer
  71.    dmColor As Integer
  72.    dmDuplex As Integer
  73.    dmYResolution As Integer
  74.    dmTTOption As Integer
  75.    dmCollate As Integer
  76.    dmFormName As String * CCHFORMNAME
  77.    dmLogPixels As Integer
  78.    dmBitsPerPel As Long
  79.    dmPelsWidth As Long
  80.    dmPelsHeight As Long
  81.    dmDisplayFlags As Long
  82.    dmDisplayFrequency As Long
  83. End Type
  84.  
  85. Type SYSTEMTIME
  86.    wYear As Integer
  87.    wMonth As Integer
  88.    wDayOfWeek As Integer
  89.    wDay As Integer
  90.    wHour As Integer
  91.    wMinute As Integer
  92.    wSecond As Integer
  93.    wMilliseconds As Integer
  94. End Type
  95.  
  96. Type JOB_INFO_2
  97.    JobId As Long
  98.    pPrinterName As Long
  99.    pMachineName As Long
  100.    pUserName As Long
  101.    pDocument As Long
  102.    pNotifyName As Long
  103.    pDatatype As Long
  104.    pPrintProcessor As Long
  105.    pParameters As Long
  106.    pDriverName As Long
  107.    pDevMode As Long
  108.    pStatus As Long
  109.    pSecurityDescriptor As Long
  110.    Status As Long
  111.    Priority As Long
  112.    Position As Long
  113.    StartTime As Long
  114.    UntilTime As Long
  115.    TotalPages As Long
  116.    Size As Long
  117.    Submitted As SYSTEMTIME
  118.    time As Long
  119.    PagesPrinted As Long
  120. End Type
  121.  
  122. Type PRINTER_INFO_2
  123.    pServerName As Long
  124.    pPrinterName As Long
  125.    pShareName As Long
  126.    pPortName As Long
  127.    pDriverName As Long
  128.    pComment As Long
  129.    pLocation As Long
  130.    pDevMode As Long
  131.    pSepFile As Long
  132.    pPrintProcessor As Long
  133.    pDatatype As Long
  134.    pParameters As Long
  135.    pSecurityDescriptor As Long
  136.    Attributes As Long
  137.    Priority As Long
  138.    DefaultPriority As Long
  139.    StartTime As Long
  140.    UntilTime As Long
  141.    Status As Long
  142.    cJobs As Long
  143.    AveragePPM As Long
  144. End Type
  145.  
  146. Public Const ERROR_INSUFFICIENT_BUFFER = 122
  147. Public Const PRINTER_STATUS_BUSY = &H200
  148. Public Const PRINTER_STATUS_DOOR_OPEN = &H400000
  149. Public Const PRINTER_STATUS_ERROR = &H2
  150. Public Const PRINTER_STATUS_INITIALIZING = &H8000
  151. Public Const PRINTER_STATUS_IO_ACTIVE = &H100
  152. Public Const PRINTER_STATUS_MANUAL_FEED = &H20
  153. Public Const PRINTER_STATUS_NO_TONER = &H40000
  154. Public Const PRINTER_STATUS_NOT_AVAILABLE = &H1000
  155. Public Const PRINTER_STATUS_OFFLINE = &H80
  156. Public Const PRINTER_STATUS_OUT_OF_MEMORY = &H200000
  157. Public Const PRINTER_STATUS_OUTPUT_BIN_FULL = &H800
  158. Public Const PRINTER_STATUS_PAGE_PUNT = &H80000
  159. Public Const PRINTER_STATUS_PAPER_JAM = &H8
  160. Public Const PRINTER_STATUS_PAPER_OUT = &H10
  161. Public Const PRINTER_STATUS_PAPER_PROBLEM = &H40
  162. Public Const PRINTER_STATUS_PAUSED = &H1
  163. Public Const PRINTER_STATUS_PENDING_DELETION = &H4
  164. Public Const PRINTER_STATUS_PRINTING = &H400
  165. Public Const PRINTER_STATUS_PROCESSING = &H4000
  166. Public Const PRINTER_STATUS_TONER_LOW = &H20000
  167. Public Const PRINTER_STATUS_USER_INTERVENTION = &H100000
  168. Public Const PRINTER_STATUS_WAITING = &H2000
  169. Public Const PRINTER_STATUS_WARMING_UP = &H10000
  170. Public Const JOB_STATUS_PAUSED = &H1
  171. Public Const JOB_STATUS_ERROR = &H2
  172. Public Const JOB_STATUS_DELETING = &H4
  173. Public Const JOB_STATUS_SPOOLING = &H8
  174. Public Const JOB_STATUS_PRINTING = &H10
  175. Public Const JOB_STATUS_OFFLINE = &H20
  176. Public Const JOB_STATUS_PAPEROUT = &H40
  177. Public Const JOB_STATUS_PRINTED = &H80
  178. Public Const JOB_STATUS_DELETED = &H100
  179. Public Const JOB_STATUS_BLOCKED_DEVQ = &H200
  180. Public Const JOB_STATUS_USER_INTERVENTION = &H400
  181. Public Const JOB_STATUS_RESTART = &H800

Pozdrav
↑  ↓

#22 14.12.2010-21:43
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,451


Subject: Re: Poruka o završetku printanja, dali može?
Nastavak koda u isti modul ide gdje je i ovaj gore kod. Nemora ali tako je bolje.
DownloadIzvorni kod (Visual Basic):
  1. Public Function GetString(ByVal PtrStr As Long) As String
  2.    Dim StrBuff As String * 256
  3.    
  4.    'Check for zero address
  5.   If PtrStr = 0 Then
  6.       GetString = " "
  7.       Exit Function
  8.    End If
  9.    
  10.    'Copy data from PtrStr to buffer.
  11.   CopyMemory ByVal StrBuff, ByVal PtrStr, 256
  12.    
  13.    'Strip any trailing nulls from string.
  14.   GetString = StripNulls(StrBuff)
  15. End Function
  16.  
  17. Public Function StripNulls(OriginalStr As String) As String
  18.    'Strip any trailing nulls from input string.
  19.   If (InStr(OriginalStr, Chr(0)) > 0) Then
  20.       OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
  21.    End If
  22.  
  23.    'Return modified string.
  24.   StripNulls = OriginalStr
  25. End Function
  26.  
  27. Public Function PtrCtoVbString(Add As Long) As String
  28.     Dim sTemp As String * 512
  29.     Dim X As Long
  30.  
  31.     X = lstrcpy(sTemp, Add)
  32.     If (InStr(1, sTemp, Chr(0)) = 0) Then
  33.          PtrCtoVbString = ""
  34.     Else
  35.          PtrCtoVbString = Left(sTemp, InStr(1, sTemp, Chr(0)) - 1)
  36.     End If
  37. End Function
  38.  
  39. Public Function CheckPrinterStatus(PI2Status As Long) As String
  40.    Dim tempStr As String
  41.    
  42.    If PI2Status = 0 Then   ' Return "Ready"
  43.      CheckPrinterStatus = "Printer Status = Ready" & vbCrLf
  44.    Else
  45.       tempStr = ""   ' Clear
  46.      If (PI2Status And PRINTER_STATUS_BUSY) Then
  47.          tempStr = tempStr & "Busy  "
  48.       End If
  49.      
  50.       If (PI2Status And PRINTER_STATUS_DOOR_OPEN) Then
  51.          tempStr = tempStr & "Printer Door Open  "
  52.       End If
  53.      
  54.       If (PI2Status And PRINTER_STATUS_ERROR) Then
  55.          tempStr = tempStr & "Printer Error  "
  56.       End If
  57.      
  58.       If (PI2Status And PRINTER_STATUS_INITIALIZING) Then
  59.          tempStr = tempStr & "Initializing  "
  60.       End If
  61.      
  62.       If (PI2Status And PRINTER_STATUS_IO_ACTIVE) Then
  63.          tempStr = tempStr & "I/O Active  "
  64.       End If
  65.  
  66.       If (PI2Status And PRINTER_STATUS_MANUAL_FEED) Then
  67.          tempStr = tempStr & "Manual Feed  "
  68.       End If
  69.      
  70.       If (PI2Status And PRINTER_STATUS_NO_TONER) Then
  71.          tempStr = tempStr & "No Toner  "
  72.       End If
  73.      
  74.       If (PI2Status And PRINTER_STATUS_NOT_AVAILABLE) Then
  75.          tempStr = tempStr & "Not Available  "
  76.       End If
  77.      
  78.       If (PI2Status And PRINTER_STATUS_OFFLINE) Then
  79.          tempStr = tempStr & "Off Line  "
  80.       End If
  81.      
  82.       If (PI2Status And PRINTER_STATUS_OUT_OF_MEMORY) Then
  83.          tempStr = tempStr & "Out of Memory  "
  84.       End If
  85.      
  86.       If (PI2Status And PRINTER_STATUS_OUTPUT_BIN_FULL) Then
  87.          tempStr = tempStr & "Output Bin Full  "
  88.       End If
  89.      
  90.       If (PI2Status And PRINTER_STATUS_PAGE_PUNT) Then
  91.          tempStr = tempStr & "Page Punt  "
  92.       End If
  93.      
  94.       If (PI2Status And PRINTER_STATUS_PAPER_JAM) Then
  95.          tempStr = tempStr & "Paper Jam  "
  96.       End If
  97.  
  98.       If (PI2Status And PRINTER_STATUS_PAPER_OUT) Then
  99.          tempStr = tempStr & "Paper Out  "
  100.       End If
  101.      
  102.       If (PI2Status And PRINTER_STATUS_OUTPUT_BIN_FULL) Then
  103.          tempStr = tempStr & "Output Bin Full  "
  104.       End If
  105.      
  106.       If (PI2Status And PRINTER_STATUS_PAPER_PROBLEM) Then
  107.          tempStr = tempStr & "Page Problem  "
  108.       End If
  109.      
  110.       If (PI2Status And PRINTER_STATUS_PAUSED) Then
  111.          tempStr = tempStr & "Paused  "
  112.       End If
  113.  
  114.       If (PI2Status And PRINTER_STATUS_PENDING_DELETION) Then
  115.          tempStr = tempStr & "Pending Deletion  "
  116.       End If
  117.      
  118.       If (PI2Status And PRINTER_STATUS_PRINTING) Then
  119.          tempStr = tempStr & "Printing  "
  120.       End If
  121.      
  122.       If (PI2Status And PRINTER_STATUS_PROCESSING) Then
  123.          tempStr = tempStr & "Processing  "
  124.       End If
  125.      
  126.       If (PI2Status And PRINTER_STATUS_TONER_LOW) Then
  127.          tempStr = tempStr & "Toner Low  "
  128.       End If
  129.  
  130.       If (PI2Status And PRINTER_STATUS_USER_INTERVENTION) Then
  131.          tempStr = tempStr & "User Intervention  "
  132.       End If
  133.      
  134.       If (PI2Status And PRINTER_STATUS_WAITING) Then
  135.          tempStr = tempStr & "Waiting  "
  136.       End If
  137.      
  138.       If (PI2Status And PRINTER_STATUS_WARMING_UP) Then
  139.          tempStr = tempStr & "Warming Up  "
  140.       End If
  141.      
  142.       'Did you find a known status?
  143.      If Len(tempStr) = 0 Then
  144.          tempStr = "Unknown Status of " & PI2Status
  145.       End If
  146.      
  147.       'Return the Status
  148.      CheckPrinterStatus = "Printer Status = " & tempStr & vbCrLf
  149.    End If
  150. End Function

Pozdrav
Ovaj komentar je mijenjan 1 puta. zadnja izmjena 14.12.2010-21:44 od strane zxz. ↑  ↓

#23 14.12.2010-21:45
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,451


Subject: Re: Poruka o završetku printanja, dali može?
Nastavak koda.
DownloadIzvorni kod (Visual Basic):
  1. Public Function CheckPrinter(PrinterStr As String, JobStr As String) As String
  2.    Dim hPrinter As Long
  3.    Dim ByteBuf As Long
  4.    Dim BytesNeeded As Long
  5.    Dim PI2 As PRINTER_INFO_2
  6.    Dim JI2 As JOB_INFO_2
  7.    Dim PrinterInfo() As Byte
  8.    Dim JobInfo() As Byte
  9.    Dim result As Long
  10.    Dim LastError As Long
  11.    Dim PrinterName As String
  12.    Dim tempStr As String
  13.    Dim NumJI2 As Long
  14.    Dim pDefaults As PRINTER_DEFAULTS
  15.    Dim I As Integer
  16.    
  17.    'Set a default return value if no errors occur.
  18.   CheckPrinter = "Printer info retrieved"
  19.    
  20.    'NOTE: You can ***** printer from the Printers Collection
  21.   'or use the EnumPrinters() API to select a printer name.
  22.  
  23.    'Use the default printer of Printers collection.
  24.   'This is typically, but not always, the system default printer.
  25. [color=#FF0000]  'Ovdje kopira ime printera iz tabele[/color]
  26.   PrinterName = "\\SERVER\Samsung ML-1640 Series"
  27.    'Set desired access security setting.
  28.   pDefaults.DesiredAccess = PRINTER_ACCESS_USE
  29.    
  30.    'Call API to get a handle to the printer.
  31.   result = OpenPrinter(PrinterName, hPrinter, pDefaults)
  32.    If result = 0 Then
  33.       'If an error occurred, display an error and exit sub.
  34.      CheckPrinter = "Cannot open printer " & PrinterName & _
  35.          ", Error: " & Err.LastDllError
  36.       Exit Function
  37.    End If
  38.  
  39.    'Init BytesNeeded
  40.   BytesNeeded = 0
  41.  
  42.    'Clear the error object of any errors.
  43.   Err.Clear
  44.  
  45.    'Determine the buffer size that is needed to get printer info.
  46.   result = GetPrinter(hPrinter, 2, 0&, 0&, BytesNeeded)
  47.    
  48.    'Check for error calling GetPrinter.
  49.   If Err.LastDllError <> ERROR_INSUFFICIENT_BUFFER Then
  50.       'Display an error message, close printer, and exit sub.
  51.      CheckPrinter = " > GetPrinter Failed on initial call! <"
  52.       ClosePrinter hPrinter
  53.       Exit Function
  54.    End If
  55.    
  56.    'Note that in Charles Petzold's book "Programming Windows 95," he
  57.   'states that because of a problem with GetPrinter on Windows 95 only, you
  58.   'must allocate a buffer as much as three times larger than the value
  59.   'returned by the initial call to GetPrinter. This is not done here.
  60.   ReDim PrinterInfo(1 To BytesNeeded)
  61.    
  62.    ByteBuf = BytesNeeded
  63.    
  64.    'Call GetPrinter to get the status.
  65.   result = GetPrinter(hPrinter, 2, PrinterInfo(1), ByteBuf, _
  66.      BytesNeeded)
  67.    
  68.    'Check for errors.
  69.   If result = 0 Then
  70.       'Determine the error that occurred.
  71.      LastError = Err.LastDllError()
  72.      
  73.       'Display error message, close printer, and exit sub.
  74.      CheckPrinter = "Couldn't get Printer Status!  Error = " _
  75.          & LastError
  76.       ClosePrinter hPrinter
  77.       Exit Function
  78.    End If
  79.  
  80.    'Copy contents of printer status byte array into a
  81.   'PRINTER_INFO_2 structure to separate the individual elements.
  82.   CopyMemory PI2, PrinterInfo(1), Len(PI2)
  83.    
  84.    'Check if printer is in ready state.
  85.   PrinterStr = CheckPrinterStatus(PI2.Status)
  86.    
  87.    'Add printer name, driver, and port to list.
  88.   PrinterStr = PrinterStr & "Printer Name = " & _
  89.      GetString(PI2.pPrinterName) & vbCrLf
  90.    PrinterStr = PrinterStr & "Printer Driver Name = " & _
  91.      GetString(PI2.pDriverName) & vbCrLf
  92.    PrinterStr = PrinterStr & "Printer Port Name = " & _
  93.      GetString(PI2.pPortName) & vbCrLf
  94.    
  95.    'Call API to get size of buffer that is needed.
  96.   result = EnumJobs(hPrinter, 0&, &HFFFFFFFF, 2, ByVal 0&, 0&, _
  97.       BytesNeeded, NumJI2)
  98.    
  99.    'Check if there are no current jobs, and then display appropriate message.
  100.   If BytesNeeded = 0 Then
  101.       JobStr = "No Print Jobs!"
  102.    Else
  103.       'Redim byte array to hold info about print job.
  104.      ReDim JobInfo(0 To BytesNeeded)
  105.      
  106.       'Call API to get print job info.
  107.      result = EnumJobs(hPrinter, 0&, &HFFFFFFFF, 2, JobInfo(0), _
  108.         BytesNeeded, ByteBuf, NumJI2)
  109.      
  110.       'Check for errors.
  111.      If result = 0 Then
  112.          'Get and display error, close printer, and exit sub.
  113.         LastError = Err.LastDllError
  114.          CheckPrinter = " > EnumJobs Failed on second call! <  Error = " _
  115.             & LastError
  116.          ClosePrinter hPrinter
  117.          Exit Function
  118.       End If
  119.      
  120.       'Copy contents of print job info byte array into a
  121.      'JOB_INFO_2 structure to separate the individual elements.
  122.      For I = 0 To NumJI2 - 1   ' Loop through jobs and walk the buffer
  123.          CopyMemory JI2, JobInfo(I * Len(JI2)), Len(JI2)
  124.              
  125.           ' List info available on Jobs.
  126.          Debug.Print "Job ID" & vbTab & JI2.JobId
  127.           Debug.Print "Name Of Printer" & vbTab & _
  128.             GetString(JI2.pPrinterName)
  129.           Debug.Print "Name Of Machine That Created Job" & vbTab & _
  130.             GetString(JI2.pMachineName)
  131.           Debug.Print "Print Job Owner's Name" & vbTab & _
  132.             GetString(JI2.pUserName)
  133.           Debug.Print "Name Of Document" & vbTab & GetString(JI2.pDocument)
  134.           Debug.Print "Name Of User To Notify" & vbTab & _
  135.             GetString(JI2.pNotifyName)
  136.           Debug.Print "Type Of Data" & vbTab & GetString(JI2.pDatatype)
  137.           Debug.Print "Print Processor" & vbTab & _
  138.             GetString(JI2.pPrintProcessor)
  139.           Debug.Print "Print Processor Parameters" & vbTab & _
  140.             GetString(JI2.pParameters)
  141.           Debug.Print "Print Driver Name" & vbTab & _
  142.             GetString(JI2.pDriverName)
  143.           Debug.Print "Print Job 'P' Status" & vbTab & _
  144.             GetString(JI2.pStatus)
  145.           Debug.Print "Print Job Status" & vbTab & JI2.Status
  146.           Debug.Print "Print Job Priority" & vbTab & JI2.Priority
  147.           Debug.Print "Position in Queue" & vbTab & JI2.Position
  148.           Debug.Print "Earliest Time Job Can Be Printed" & vbTab & _
  149.             JI2.StartTime
  150.           Debug.Print "Latest Time Job Will Be Printed" & vbTab & _
  151.             JI2.UntilTime
  152.           Debug.Print "Total Pages For Entire Job" & vbTab & JI2.TotalPages
  153.           Debug.Print "Size of Job In Bytes" & vbTab & JI2.Size
  154.           'Because of a bug in Windows NT 3.51, the time member is not set correctly.
  155.          'Therefore, do not use the time member on Windows NT 3.51.
  156.          Debug.Print "Elapsed Print Time" & vbTab & JI2.time
  157.           Debug.Print "Pages Printed So Far" & vbTab & JI2.PagesPrinted
  158.              
  159.           'Display basic job status info.
  160.          JobStr = JobStr & "Job ID = " & JI2.JobId & _
  161.              vbCrLf & "Total Pages = " & JI2.TotalPages & vbCrLf
  162.          
  163.           tempStr = ""   'Clear
  164.          'Check for a ready state.
  165.          If JI2.pStatus = 0& Then   ' If pStatus is Null, check Status.
  166.            If JI2.Status = 0 Then
  167.                tempStr = tempStr & "Ready!  " & vbCrLf
  168.             Else  'Check for the various print job states.
  169.               If (JI2.Status And JOB_STATUS_SPOOLING) Then
  170.                   tempStr = tempStr & "Spooling  "
  171.                End If
  172.                
  173.                If (JI2.Status And JOB_STATUS_OFFLINE) Then
  174.                   tempStr = tempStr & "Off line  "
  175.                End If
  176.                
  177.                If (JI2.Status And JOB_STATUS_PAUSED) Then
  178.                   tempStr = tempStr & "Paused  "
  179.                End If
  180.                
  181.                If (JI2.Status And JOB_STATUS_ERROR) Then
  182.                   tempStr = tempStr & "Error  "
  183.                End If
  184.                
  185.                If (JI2.Status And JOB_STATUS_PAPEROUT) Then
  186.                   tempStr = tempStr & "Paper Out  "
  187.                End If
  188.                
  189.                If (JI2.Status And JOB_STATUS_PRINTING) Then
  190.                   tempStr = tempStr & "Printing  "
  191.                End If
  192.                
  193.                If (JI2.Status And JOB_STATUS_USER_INTERVENTION) Then
  194.                   tempStr = tempStr & "User Intervention Needed  "
  195.                End If
  196.                
  197.                If Len(tempStr) = 0 Then
  198.                   tempStr = "Unknown Status of " & JI2.Status
  199.                End If
  200.             End If
  201.         Else
  202.             ' Dereference pStatus.
  203.            tempStr = PtrCtoVbString(JI2.pStatus)
  204.         End If
  205.          
  206.           'Report the Job status.
  207.          JobStr = JobStr & tempStr & vbCrLf
  208.           Debug.Print JobStr & tempStr
  209.       Next I
  210.    End If
  211.    
  212.    'Close the printer handle.
  213.   ClosePrinter hPrinter
  214. End Function

Obrati paznju sto je obiljezeno crvenim.
Tu trebas upisati ime tvog printera iz tabele sa podacima iz predhodnog koda.
Onaj kod ti nece vise trebati.
Bar ne za ovo sto ti treba pa ga mozes i skloniti. Bio je samo zbog toga da ti da pravo ime printera.
Pozdrav
↑  ↓

#24 14.12.2010-21:56
zxz Online
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 9,451


Subject: Re: Poruka o završetku printanja, dali može?
E sad dolazi poziv.
Najbolje da napravis jednu formu koju ces podici pa moze biti i nevidljiva.
Forma je samo radi tajmera da nebi kucao kod i za tajmer.
Na on Timer forme mozes postaviti ovaj kod:
DownloadIzvorni kod (Visual Basic):
  1. Private Sub Form_Timer()
  2.    Dim PrinterStatus As String
  3.    Dim JobStatus As String
  4.    Dim ErrorInfo As String
  5.    
  6.    'Clear the status info for new info/status.
  7.  
  8.    
  9.    'Call sub to perform check.
  10.   'Debug.Print CheckPrinter(PrinterStatus, JobStatus)
  11.   'Debug.Print PrinterStatus
  12.   'Debug.Print JobStatus
  13.   'Forms!Form1.T = JobStatus & " " & vbCr & PrinterStatus
  14.   MsgBox JobStatus & " " & vbCr & PrinterStatus
  15. End Sub
Timer interval mozes staviti napr 5000 ili mozda vise.
Printer status funkciju mozes i pobrisati ako ti netreba.
Koliko se sjecam tebi samo treba job status.

Kada sve isprobas onda ti tu treba i jedan iff da ti javlja samo ako je printer slobodan mada ni to nijje mozda dovoljno dobro nego da ti javlja samo kada ga ukljucis i kada je printer slobodan.
O tom po tom.
Prvo probaj ovo proraditi.
Pozdrav
↑  ↓

Stranice (2): 1, 2


All times are GMT +01:00. Current time: 22.10.2017-11:05.