Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Remove/Delete A Print Spool Using SetJob And EnumJobs In Winspool.drv


I have a Genicom label printer on a Win98 machine that has a horrible driver. When spooling multiple jobs sometimes the printer locks up (I have explored many options to no avail (network card, latest driver, etc). The best fix is to remove any spools from the print queue and re-spool them. The problem is once the job is running it can't be removed by using the standard right-click "Cancel Job" option. I have to reboot and select the "Delete Jobs" option that pops up when windows loads (I'm not sure what process is serving this up, "spool32.exe"?).

My question becomes: How do I do that in VB6 code?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Print Spool
Hi Everyone,
I am printing a Word document thru a VB program.  I am familiar with the BackgroundPrintingStatus property to determine when I can dismiss the Word application object.  I need to know when the printer is free i.e., print spool is empty.  It does not appear the the printer object gives me this information.  Is there a way I can tell when the print spool is empty...perhaps thru some type of API function?
Please advise.
Thanks in advance.
Regards,
RPrinceton

Print Spool Files
I want to intercept files to the printer and redirect them to a different printer. I have paused my printer and have a collection of spool files (.spl) but I dont know how to get them to go where I want. I have tried copying them to the new device but this does not work. Any suggestions ?

Path For Print Spool File
I'm building an application that captures the *.spl files send to a printer.
I pause the printer and then I want to copy the spool files send to that printer and then resume the printer again.

How do I get to the specific file path or file name of the spool files, because every document send to any printer will be send to the same spool directory. And I only want to copy those who are sent to the specified printer.

with getjob, I only can get the document name. but that isn't the same as the spool file name

I'd appreciate a quick answer

greetz
DonaldVdD

Print Finished Exe/spool Stays Active
After printing forms with a VB app, you can exit the app but when you check the task manager, the exe is still active. Spool stays active.

Is there any command which can kill this when the printing is finished.

Ask About Setjob Api 's Problem Plz
........................
.......................
SetJob hPrinter, .JobId, 0, vbNull, JOB_CONTROL_CANCEL
ClosePrinter(hPrinter)
end sub

i test print form notepad and cancel job by this code
if it's a 1st job and cancel by this code
printer's stop.
probelm is
print q list can't delete this job .it's status "Deleting-Printing-Printed"
and can't manual cancel this job too...(must remove printer's driver and reinstall printer)

how can i solve,fix this problem

thanks.

SetJob And SetPrinter API's - Please Help!
hi there

thanks for taking the time out of our programming schedule to give me a hand with these api calls.

i need to be able to set the status of a printjob using the setjob api, and set the status of the printer using the setprinter api.

Could you give me a hand with the code to pause the device and job.

thanks.

Andrew

Winspool.drv Api Declarations
Has anyone typed out the vb declarations for all the functions and structures in winspool.drv?  Or does anyone know where to get it?

I'm talking about all the lines that look like this:


Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrn As Long) As Long


I can't seem to find it on the net.  Please help, it would save me alot of time!

cheyney

Using Setjob API To Pause Printer Queue
Hi
I'm using VB6 and I am trying to ensure that print job sent to the printer queue are printed in the order that they are sent. I believe (and correct me if I'm wrong) that print jobs needs to be paused in order to "link" them together. I understand that the API "setjob" is used for this. I know the declaration but I don't really understand how to use this function and the parameters that are needed. I also believe the "openprinter" API also has to be used to return the printer handle in conjunction with the "setjob". I'm not sure how this is done either.

If anyone can hep me out with some code examples, I would be most appreciative.

Thanks so much
Richard

Printer Driver = Winspool, PLEASE HELP!
My developing environment is as follow:
Window 2000 Professional
Visual Basic 6.0 with service pact 5
Crystal Report 9.0


Here are part of my program for printing out the report

Dim prt As Printer

For Each prt In Printers
If prt.DeviceName = "HP LaserJet 4/4M Plus PS 600" Then
Set Printer = prt
Report.SelectPrinter prt.DriverName, prt.DeviceName, prt.Port
Exit For
End If
Next

Report.PrintOut

I am using the above codes to call the SelectPrinter function, but what I get for prt.DriverName is "winspool". Connection error occured as a result. Any idea how can I get the real name for my printer driver?

Please help!

Do I Use Remove Or Delete?
Hello VB Gurus,
I having some problems trying to delete two data strings within two fields on a MSAccess Dbase.
The following code inserts my data strings to the
Dbase but I having difficulty deleting my data
from my Dbase
Any hints as to hwo I would modify the below code
to remove what I have added?


Dim dbName As Database

Dim A As String
A = txtsubjectcode.Text

Dim B As String
B = txtsubject.Text

'Store data in "A & B" variables taken from textbox txtsubjectcode.Text
'Open Database and ADD text entrys to field columns;ie (SubjectCode, Subject)


Set dbName = OpenDatabase("C:WINNTProfilesAdministratorDesktopRnrbooks.mdb")
dbName.Execute "INSERT INTO Subjects" & "(SubjectCode, Subject) VALUES" & "('" & A & "','" & B & "');"

dbName.Close


Juan Amore

Datarowstate=delete--how To Remove
I'm getting an error when updating the (vb.net) dataadapter wit records where the datarowstate = Deleted in my dataset. I hav no problem when issuing da.update on Deleted state records wher the datasource is a Sql table that has a primary key set, but i doesn't like da.update when the datasource is a Sql table wit no primary key. Any way around it?

Delete Or Remove From The Dcomcnfg
hai gurus
How to delete the applications from the dcomcng (DCOM confiuraiton properties)

I registred one Activex exe so many places in my computer
So in dcomcnfg I saw too many applications,I am not understanding which application is running
Thanx in advance
Rajender

Delete Or Remove Makro
Haw can i delete or remove a particular makro from Normal.dot.
I work with the VB6.0.
Thank's.
Boris.

Total Number Of Pages Printed Using API/winspool.drv
I want to create some kind of report (or table) with the total number of printed pages from our printers. I've been able to find the code to show the number of current printjobs in a printqueue, but is it possible to modify it so I can get a total number of printed pages? Here's the most important part of code for the number of prints in the printqueue:
-------------

Code:
Option Explicit

Public Type JOB_INFO_1_API
JobId As Long
pPrinterName As Long
pMachineName As Long
pUserName As Long
pDocument As Long
pDatatype As Long
pStatus As Long
Status As Long
Priority As Long
Position As Long
TotalPages As Long
PagesPrinted As Long
Submitted As SYSTEMTIME
End Type

Public Type JOB_INFO_1
JobId As Long
pPrinterName As String
pMachineName As String
pUserName As String
pDocument As String
pDatatype As String
pStatus As String
Status As Long
Priority As Long
Position As Long
TotalPages As Long
PagesPrinted As Long
Submitted As SYSTEMTIME
End Type

'API Declarations
Public 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, ByVal pJob As Long, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long
Public Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long

'Get the number of Jobs in the specified Printer Queue (max 128)... the PrinterName can be a network path: "\MYSERVERMYPRINTER"
Function GetPrinterQueue(PrinterName As String) As Long
Dim PrinterStruct As PRINTER_DEFAULTS
Dim HPrinter As Long
Dim ret As Boolean
Dim Jobs(0 To 127) As JOB_INFO_1_API
Dim pcbNeeded As Long
Dim pcReturned As Long
Dim i As Integer
Dim TempBuff As Long

'Initialize the Printer structure
PrinterStruct.pDatatype = vbNullString
PrinterStruct.pDevMode.dmSize = Len(PrinterStruct.pDevMode)
PrinterStruct.DesiredAccess = PRINTER_ACCESS_USE
'Get the printer Handle
ret = OpenPrinter(PrinterName, HPrinter, PrinterStruct)
'Get the Printer active jobs
ret = EnumJobs(HPrinter, 0, 127, 1, TempBuff, 0, pcbNeeded, pcReturned)
If pcbNeeded = 0 Then
GetPrinterQueue = 0
Else
'Allocate the Buffer
TempBuff = HeapAlloc(GetProcessHeap(), 0, pcbNeeded)
ret = EnumJobs(HPrinter, 0, 127, 1, TempBuff, pcbNeeded, pcbNeeded, pcReturned)
CopyMem Jobs(0), ByVal TempBuff, pcbNeeded
For i = 0 To pcReturned - 1
JobsDesc(i).pPrinterName = LPSTRtoSTRING(Jobs(i).pPrinterName)
JobsDesc(i).pMachineName = LPSTRtoSTRING(Jobs(i).pMachineName)
JobsDesc(i).pUserName = LPSTRtoSTRING(Jobs(i).pUserName)
JobsDesc(i).pDocument = LPSTRtoSTRING(Jobs(i).pDocument)
JobsDesc(i).pDatatype = LPSTRtoSTRING(Jobs(i).pDatatype)
JobsDesc(i).pStatus = LPSTRtoSTRING(Jobs(i).pStatus)
JobsDesc(i).JobId = Jobs(i).JobId
JobsDesc(i).Status = Jobs(i).Status
JobsDesc(i).Priority = Jobs(i).Priority
JobsDesc(i).Position = Jobs(i).Position
JobsDesc(i).TotalPages = Jobs(i).TotalPages
JobsDesc(i).PagesPrinted = Jobs(i).PagesPrinted
JobsDesc(i).Submitted = Jobs(i).Submitted
Next
If TempBuff Then HeapFree GetProcessHeap(), 0, TempBuff
GetPrinterQueue = pcReturned
End If
'Close printer
ret = CloseHandle(HPrinter)
End Function

Private Sub cmdInQueue_Click()
'Get the Printer's Queue
MsgBox "Number of jobs in queue: " & GetPrinterQueue("\servername" & _
InputBox("Give printername:", "Printername"))
End Sub
---------------------------
Thanks in advance,

Menno Kuiper
the Netherlands

Text Size And Font Names In Winspool.drv
hi all
following is the code useing in my application, when i direct the file to be prinited in fast way , its printing correct but i cant able print in bold letters and in different fonts, please help

Option Explicit
Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Declare Function EndDocPrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Declare Function EndPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long
Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" (ByVal hPrinter As Long, ByVal level As Long, pDocInfo As DOC_INFO_1) As Long
Declare Function StartPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Declare Function WritePrinter Lib "winspool.drv" (ByVal hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, pcWritten As Long) As Long
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type

Type PRINTER_DEFAULTS
pDatatype As String
pDevMode As DEVMODE
DesiredAccess As Long
End Type
Type DOC_INFO_1
pDocName As String
pOutputFile As String
pDatatype As String
End Type
Public Sub OpenDocForPrint()
Dim strFileText As String
Dim intFile As Integer
Dim strTextToPrint As String
intFile = FreeFile
On Error GoTo Err_Trap
Open "C:p1" For Input As intFile
Do While Not EOF(intFile)
Line Input #intFile, strFileText
strTextToPrint = strTextToPrint & strFileText & vbCrLf
Loop
Close intFile
strTextToPrint = strTextToPrint & vbFormFeed
Call PrintThatFile(strTextToPrint)
Exit Sub
Err_Trap:
If Err.Number = "75" Then
ElseIf Err.Number = "53" Then
MsgBox "File Not Found", vbOKOnly, "Llamas Rule"
Exit Sub
Else
MsgBox Err.Description, vbOKOnly, Err.Number
End If
End Sub
'Get default printer or use specified printer then spool and print
Public Sub PrintThatFile(strText As String, Optional strPrinter As Variant)
Dim lngPrnHndl As Long
Dim Written As Long
Dim strWrite As String
Dim typDOC As DOC_INFO_1
Dim PrnDef As PRINTER_DEFAULTS
Dim lngCnt As Long
Dim lngFlen As Long
Dim strPrnName As String
Dim strReturn As String
Dim intReturn As Integer
If IsMissing(strPrinter) Then
strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", strReturn, Len(strReturn))
If intReturn Then
strPrnName = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
Else
strPrnName = InputBox("No default Printer Listed, you must provide a Printer name", "Llama Print")
End If
Else
strPrnName = strPrinter
End If
typDOC.pDocName = "Llama Printer"
typDOC.pOutputFile = vbNullString
typDOC.pDatatype = vbNullString
Call OpenPrinter(strPrnName, lngPrnHndl, PrnDef)
Call StartDocPrinter(lngPrnHndl, 1, typDOC)
Call StartPagePrinter(lngPrnHndl)
Call WritePrinter(lngPrnHndl, ByVal strText, Len(strText), Written)
Call EndPagePrinter(lngPrnHndl)
Call EndDocPrinter(lngPrnHndl)
Call ClosePrinter(lngPrnHndl)
End Sub


thanks
parthi

Please Help With Code Snippet (delete And Remove)
Hi there!

This is Carlos from Spain.

I have written code that's supposed to do the following:

Imagine you've got a dataset (BdPassengersDataSet) with a single datatable object (dtPassengers). Then you have a Windows Form with a combobox (cmbboxPassengersDel) from which you can pick up one among several rows based on their index. The row you have just chosen is to be deleted from the dataset this combobox is binded to (dtPassengers).

My intention is to first mark the chosen row as merely deleted to finally have it removed (not just marked as deleted anymore) from the dataset.

To delete the previously chosen row we use the btnDel Button object

Does the following code manage to do that? I know it truly deletes the row (up until the "End Try" statement) but I'm not sure about it being able to finally remove it.

Please remember that I'm a newie at programming with VB.NET as well as with working in an ADO.NET environment, so please have mercy! Any suggestions to optimize the code will be appreciated.

The main form in my app is called FormMain (my app's main screen so to speak)

I'm using an OLEDBClient for all connection purposes (the source database is an access file)

Thanks in advance!


code follows:



Code:
Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click

BdPassengersDataSet.dtPassengers.Rows(cmbboxPassengersDel.SelectedIndex).Delete()

Try

If MessageBox.Show("a record is about to be deleted from the database. Do you wish to continue?", _
MessageBoxIcon.Question.ToString, MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.Cancel Then
BdPassengersDataSet.RejectChanges()
FormMain.Activate()
ElseIf DialogResult.OK Then
Me.DtPassengersTableAdapter.Update(Me.BdPassengersDataSet.dtPassengers)
BdPassengersDataSet.AcceptChanges()

End If

Catch ex As Exception
MessageBox.Show("The record could not be deleted")
BdPassengersDataSet.RejectChanges()
FormMain.Activate()

End Try

Dim MyDeletedRow As Data.DataRow = BdPassengersDataSet.dtPassengers.Item(cmbboxPassengersDel.SelectedIndex)
Dim drows As Data.DataRowCollection = BdPassengersDataSet.dtPassengers.Rows

If MyDeletedRow.RowState = Data.DataRowState.Deleted Then

For Each MyDeletedRow In drows
drows.Remove(MyDeletedRow)
Next

End If

MessageBox.Show("a record has been successfully removed from the database")

End Sub

Remove Application From Ctrl+Alt+Delete?? How
Does anyone know how to remove or hide an application from being Ctrl+Alt+Del outted?
I just want to remove it from that list that appears.



This is my final problem in a program that has been bugging me for days.
regards
M.

EnumJobs / Get Job ??
I am trying to query a print queue using EnumJobs, but can only enumerate the total number of jobs in the queue. Poor ole newbie me can't figure out how to get into the array data. Within the code below (Thanks to AndreaVB.com) - how do I pull back for e.g. a list of document names, jobid's etc. etc. ??

Function GetPrinterQueue(PrinterName As String) As Long
    Dim PrinterStruct As PRINTER_DEFAULTS
    Dim hPrinter As Long
    Dim ret As Boolean
    Dim Jobs(0 To 127) As JOB_INFO_1_API
    Dim pcbNeeded As Long
    Dim pcReturned As Long
    Dim i As Integer
    Dim TempBuff As Long

    'Initialize the Printer structure
    PrinterStruct.pDatatype = vbNullString
    PrinterStruct.pDevMode.dmSize = Len(PrinterStruct.pDevMode)
    PrinterStruct.DesiredAccess = PRINTER_ACCESS_USE
    'Get the printer Handle
    ret = OpenPrinter(PrinterName, hPrinter, PrinterStruct)
    'Get the Printer active jobs
    ret = EnumJobs(hPrinter, 0, 127, 1, TempBuff, 0, pcbNeeded, pcReturned)
    If pcbNeeded = 0 Then
        GetPrinterQueue = 0
    Else
        'Allocate the Buffer
        TempBuff = HeapAlloc(GetProcessHeap(), 0, pcbNeeded)
        ret = EnumJobs(hPrinter, 0, 127, 1, TempBuff, pcbNeeded, pcbNeeded, pcReturned)
        CopyMem Jobs(0), ByVal TempBuff, pcbNeeded
        For i = 0 To pcReturned - 1
            JobsDesc(i).pPrinterName = LPSTRtoSTRING(Jobs(i).pPrinterName)
            JobsDesc(i).pMachineName = LPSTRtoSTRING(Jobs(i).pMachineName)
            JobsDesc(i).pUserName = LPSTRtoSTRING(Jobs(i).pUserName)
            JobsDesc(i).pDocument = LPSTRtoSTRING(Jobs(i).pDocument)
            JobsDesc(i).pDatatype = LPSTRtoSTRING(Jobs(i).pDatatype)
            JobsDesc(i).pStatus = LPSTRtoSTRING(Jobs(i).pStatus)
            JobsDesc(i).JobId = Jobs(i).JobId
            JobsDesc(i).Status = Jobs(i).Status
            JobsDesc(i).Priority = Jobs(i).Priority
            JobsDesc(i).Position = Jobs(i).Position
            JobsDesc(i).TotalPages = Jobs(i).TotalPages
            JobsDesc(i).PagesPrinted = Jobs(i).PagesPrinted
            JobsDesc(i).Submitted = Jobs(i).Submitted
        Next
        If TempBuff Then HeapFree GetProcessHeap(), 0, TempBuff
        GetPrinterQueue = pcReturned
    End If
    'Close printer
    ret = CloseHandle(hPrinter)
End Function

Any help much appreciated.

EnumJobs API Call
With two print jobs queued, the first Win32 API call to EnumJobs, shown below,

retval = EnumJobs(hPrinter, 0, 100, 2, ByVal 0, 0, needed, numitems)

returns retval = 1 and needed = numitems = 0. It should have returned retval = 0, numitems = 2, and needed = a non-zero number of bytes needed in the byte buffer to be filled with Job_Info_2 data during the second call to EnumJobs. What gives? Im running vanilla VB 6 SP4 on Windows 95 and have a single printer, an Epson Color Stylus 600. The api calls correctly identify the name of my printer, and the hwnd value returned for the printer (hPrinter = 5308460) appears to be correct.

Im also experiencing a similar problem with GetPrinter, for which I am never able to get a cJobs return value of anything other than zero.

John Fritch

EnumJobs: Can't Get To Square One
With two print jobs queued, the first call to EnumJobs, shown below,

retval = EnumJobs(hPrinter, 0, 100, 2, ByVal 0, 0, needed, numitems)

returns retval = 1 and needed = numitems = 0. It should have returned retval = 0, numitems = 2, and needed = a non-zero number of bytes needed in the byte buffer to be filled with Job_Info_2 data during the second call to EnumJobs. What gives? I’m running vanilla VB 6 SP4 on Windows 95 and have a single printer, an Epson Color Stylus 600. The api calls correctly identify the name of my printer, and the hwnd value returned for the printer (hPrinter = 5308460) appears to be correct.

I’m also experiencing a similar problem with GetPrinter, for which I am never able to get a cJobs return value of anything other than zero.

John Fritch

Hi I'm Using Enumjobs AP Function And I Have A Problem
i'm using enumjobs to count the number of pages printed in a printer on a network , I have the printer on a win200 host and i use other w200 the function count perfectly but when i use it with W9x the number of pages printed that the program gives me is '0'

somebody knows why  ?

thanx
  

Extracting Machine Name From EnumJobs APi
Hi all
    I need help from experts of API.
im using EnumJobs API to get the Print Job details. I used both levels (JOB_INFO_1 & JOB_INFO_2)
to get the the machine name which created the Print Job using the member pMachineName. But both levels
doesn't give the machine name ( which created the PrintJob ) correctly. Have any of u had this kind of problem? .
 In some times, the pMachineName member returns 0.
Im running my program in VB 6.with Win NT4.0.
I think, it may be a problem with EnumJobs.

The code I used to achieve is as follows

Private Sub CheckPrinterJobStatus(prName As String)
  Dim ST As SYSTEMTIME ' ST holds current System date and     'Time
    Dim JobId As Long 'Job ID in the Printer Q.
   Dim hPrinter As Long
   Dim ByteBuf As Long
   Dim BytesNeeded As Long
  Dim JI2 As JOB_INFO_2
   Dim JobInfo() As Byte
     Dim result As Long
   Dim LastError As Long
   Dim tempStr As String
   Dim NumJI2 As Long ‘ No of Job Info 2 structures returned by the EnumJobs
   Dim pDefaults As PRINTER_DEFAULTS
   Dim I As Integer
   Dim msg As String
   Dim PrinterName As String, machinename As String, UserName As String
   Dim DocumentName As String , pStatus As Long
   'Set a default return value if no errors occur.
   msg = "Printer info retrieved....."
   
   sbrPrinter.Panels(1).Text = msg
   PrinterName = prName
   'Set desired access security setting.
    pDefaults.DesiredAccess = PRINTER_ACCESS_USE
   
   'Call API to get a handle to the printer.
   result = OpenPrinter(PrinterName, hPrinter, pDefaults)
   If result = 0 Then
      'If an error occurred, display an error and exit sub.
       msg = "Cannot open printer " & PrinterName & _
         ", Error: " & Err.LastDllError
           sbrPrinter.Panels(1).Text = msg
         Exit Sub
   End If
   'Init BytesNeeded
   BytesNeeded = 0
   'Clear the error object of any errors.
   Err.Clear
   
   'Call API to get size of buffer that is needed.
   result = EnumJobs(hPrinter, 0&, &HFFFFFFFF, 2, ByVal 0&, 0&, _
      BytesNeeded, NumJI2)
   'Check if there are no current jobs, and then display appropriate message.
   If BytesNeeded = 0 Then
        msg = "No Print Jobs for the given Printer!"
        sbrPrinter.Panels(1).Text = msg
        lvwPrinter.ListItems.Clear
   Else
   ByteBuf = BytesNeeded
      'Redim byte array to hold info about print job.
      ReDim JobInfo(0 To BytesNeeded)
      'Call API to get print job info.
      result = EnumJobs(hPrinter, 0&, &HFFFFFFFF, 2, JobInfo(0), _
        BytesNeeded, ByteBuf, NumJI2)
     'Check for errors.
      If result = 0 Then
         'Get and display error, close printer, and exit sub.
         LastError = Err.LastDllError
         msg = "EnumJobs Failed to iterate Print Jobs. " _
            & LastError
           sbrPrinter.Panels(1).Text = msg
         ClosePrinter hPrinter
         Exit Sub
      End If
    'clear list view to referesh the job list
      lvwPrinter.ListItems.Clear
      'Copy contents of print job info byte array into a
      'JOB_INFO_2 structure to separate the individual elements.
       For I = 0 To NumJI2 - 1 ' Loop through jobs and walk the buffer
          CopyMemory JI2, JobInfo(I * Len(JI2)), Len(JI2)
          'List info available on Jobs.
          JobId = JI2.JobId
          PrinterName = GetString(JI2.pPrinterName)
          machinename = GetString(JI2.pMachineName)
          UserName = GetString(JI2.pUserName)
          DocumentName = GetString(JI2.pDocument)
          TotalPages = JI2.TotalPages
          'jobSize = JI2.Size
 ‘ add job info into a list view
 SetPrinterInfo JobId, PrinterName, machinename, UserName, DocumentName,
      Next I
   End If
   'Close the printer handle.
   ClosePrinter hPrinter
End Sub

Private Function GetString(ByVal PtrStr As Long) As String
   Dim StrBuff As String * 256
   'Check for zero address
   If PtrStr = 0 Then
      GetString = " "
      Exit Function
   End If
   'Copy data from PtrStr to buffer.
   CopyMemory ByVal StrBuff, ByVal PtrStr, 256
   'Strip any trailing nulls from string.
   GetString = StripNulls(StrBuff)
End Function

Private Function StripNulls(OriginalStr As String) As String
   'Strip any trailing nulls from input string.
   If (InStr(OriginalStr, Chr(0)) > 0) Then
      OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
   End If
  'Return modified string.
   StripNulls = OriginalStr
End Function

Private Function PtrCtoVbString(ByVal Add As Long) As String
    Dim sTemp As String * 512
    Dim X As Long
    X = lstrcpy(sTemp, Add)
    If (InStr(1, sTemp, Chr(0)) = 0) Then
         PtrCtoVbString = ""
    Else
         PtrCtoVbString = Left(sTemp, InStr(1, sTemp, Chr(0)) - 1)
    End If
End Function


I googled to find the solution. But no luck. I attached graphical representation to best understand my
 Situation
The ultimate aim of this is to monitoring the Print Jobs from client Machines. So that it is easy to find who has given the print job to prevent the unnecessary usage of Printer.

Thanks in Adv.
Jsam.

ENUMJOBS, Buffer Size Question
Okay, I'm fairly new to VB, and I'm having trouble with this print logging program I'm working on. www.allapi.net told me to use the GetLastError command to figure out the buffer size, but for the life of me, I can't figure out how. I have tried all kinds of stuff, but I keep getting a return of 0.

I've been stuck on this for a few days, so if anyone can help, feel free to make it REALLY simple. Pretend you're talking to a high school student who didn't start VB until late last January.

Please Help Me Solve The Error In Enumjobs..code Given
Thanks to the Merrion computing team for the print information sample code.

but still I have a small problem in getting the total number of pages and the printed pages values. Other info like the document name and the owner of the print job's name I am able to get.
When I monitor the system print manager at the same time neither it displays the total pages count.
why is this problem?and how can I solve this problem?


part of the sample code wher I have the problem is given below: (this code was taken from the sample given by the Merrion computing)

    'Display basic job status info
    List2.AddItem "Job ID = " & JI2.JobId
    List2.AddItem "Total Pages = " & JI2.TotalPages
    List2.AddItem "Job Time = " & JI2.time
    List2.AddItem "Printed Pages = " & JI2.PagesPrinted
    List2.AddItem "Machine = " & GetString(JI2.pMachineName)
    List2.AddItem "User = " & GetString(JI2.pUserName)
    List2.AddItem "Document = " & GetString(JI2.pDocument)
    List2.AddItem "Job status = " & JI2.pStatus


all of the other info like the status, docname, jobid and username are all being displayed.
but the JI2.PagesPrinted and JI2.TotalPages are not displayed.


I am very thankful to all the helping people here in the vbcity.com

Peter Wesly



 

Edited by - weslypriya on 6/2/2004 12:23:43 AM

Can Printer Software Usurp GetPrinter And EnumJobs?
In my desperate search for an event or a flag that will tell me when I can delete graphics files referenced in an html page being printed, I focused on the Win32 API calls GetPrinter and EnumJobs. I have tested at least four examples of VB code implementing these calls (the best of which is the Printer Info Control at http://www.domaindlx.com/e_morcillo/...d/printer.asp), and no matter what I do, GetPrinter always returns Printer_Info_2.cJobs = 0 and EnumJobs always returns pcReturned = 0, both of which mean no jobs in the printer queue. This is true even with the Epson print spooler showing one job printing and several others in the queue.

The problem might be that the Windows print spooler is usurped by my Epson Stylus Color 600 print spooler, and the Win32 API calls reference only the former, but not the latter. Consistent with this explanation is the following observation. The Windows print spooler is displayed by selecting Start, Settings, and Printers, and then, from the resulting Printers window, right-clicking Epson Stylus Color 600 and selecting Open from the context menu. As I add print jobs to this printer, the jobs never appear in the Windows print spooler, but always appear in the Epson print spooler.

So I have two questions: (1) Am I right in concluding that my Epson printer software has effectively disabled the Win32 API print spooler calls such as EnumJobs and GetPrinter by usurping the Windows print spooler? (2) If so, how would one get an event or a flag that indicates when graphics files may be deleted without adversely impacting the printing of an html document that references them? As I have indicated in an earlier post, the HTMLWindow2.onafterprint event fires too soon for this purpose.

Im running VB6 SP4 on Windows 95.

John Fritch

Can Printer Software Usurp GetPrinter And EnumJobs?
In my desperate search for an event or a flag that will tell me when I can delete graphics files referenced in an html page being printed, I focused on the Win32 API calls GetPrinter and EnumJobs. I have tested at least four examples of VB code implementing these calls (the best of which is the “Printer Info Control” at http://www.domaindlx.com/e_morcillo...cod/printer.asp), and no matter what I do, GetPrinter always returns Printer_Info_2.cJobs = 0 and EnumJobs always returns pcReturned = 0, both of which mean “no jobs in the printer queue.” This is true even with the Epson print spooler showing one job printing and several others in the queue.

The problem might be that the Windows print spooler is usurped by my Epson Stylus Color 600 print spooler, and the Win32 API calls reference only the former, but not the latter. Consistent with this explanation is the following observation. The Windows print spooler is displayed by selecting “Start,” “Settings,” and “Printers,” and then, from the resulting “Printers” window, right-clicking “Epson Stylus Color 600” and selecting “Open” from the context menu. As I add print jobs to this printer, the jobs never appear in the Windows print spooler, but always appear in the Epson print spooler.

So I have two questions: (1) Am I right in concluding that my Epson printer software has effectively disabled the Win32 API print spooler calls such as EnumJobs and GetPrinter by usurping the Windows print spooler? (2) If so, how would one get an event or a flag that indicates when graphics files may be deleted without adversely impacting the printing of an html document that references them? As I have indicated in an earlier post, the HTMLWindow2.onafterprint event fires too soon for this purpose.

I’m running VB6 SP4 on Windows 95.

John Fritch

How To Disable Or Remove Print Icon On Data Report
Hi All,

Any one please let me know how to disable or remove the print icon on a Visual Basic 6.0 Data Report. I want do not want a user print the report from here. I will use 'DataReport1.PrintReport False' to print because when a report is printed I need to update a Database column.

Thanking you in advance.

Mr. Utpal Sikdar

How To Disable Or Remove The Print Icon On Data Report
Hi,

Would you please let me know how to disable or remove the print icon on a Visual Basic 6.0 Data Report. I do not want a user print the report from here. I will use 'DataReport1.PrintReport False' to print because when a report is printed I need to update a Database column.

Thanks,
U. Sikdar


vikramjb : Thread moved to the reporting section from database section



Edited by - vikramjb on 12/28/2005 4:04:29 AM

Spool Like Under Sql+
when i use oracles sql+ (or oracle worksheet) i can use the commands "spool <filename>" and "spool off" to save a logfile to the drive.

now i need to do a program that gives me a log each sql that is done.
but since "spool" does not seem to be a regular sql-command, i have a problem with that.

does anyone know how to get a log?
(the ora-errors are not enough)

it does not mater if it is rdo, ado or something else.

Delete Print Jobs
Would any of you know how I would begin to delete a print job from VB?

Regards,


Matt.

Not To Delete Text Using Print
Hi there.

I need to know, is there a way to tell VB not to erase the text's on the form when using print? I mean, if there is text on the form like:


Code:

print "hi"


and then we say:


Code:

msgbox("boo!")


it is gonna go over that text and wipe it.

is there a way to stop it from doing that?

yes, sure, we can create labels and text boxes to store this informtation but it is in a for loop and dunno how many to create etc...

part of my code is like this


Code:

If askyouorme = vbNo Then
For x = 1 To askhowmanypartitions
sizeofpartition = InputBox("Please enter Size of Partition number " + CStr(x) + " in MB", "Size of Partition Number " + CStr(x))
If CLng(sizeofpartition) <= CLng(txthddsize.Text) - 4 Then
totalsize = totalsize + CLng(sizeofpartition)
cutitagain = Trim(sizeofpartition)
MsgBox (cutitagain)
Print #1, cutitagain
Print
Print Tab(37); x; Tab(64); cutitagain; " MB"


If CLng(totalsize) > CLng(txthddsize.Text) Then
Dim errmsg As String
errmsg = MsgBox("Sorry, the total sizes have entered has exceeded the total capacity of the HDD, please try again", vbCritical, "Error")
End
End If

End If
end if


thanks

Monitoring Spool
Hello
I need information about how to use the functions of API Windows FindFirstPrinterChangeNotification,
WaitForSingleObject and FindNextPrinterChangeNotification with an example because is too difficult works with these for me.
I works on Visual Basic 6.0 and need monitor queue for save the result of the impression on my database

Thanks for all

Delete All Jobs From Print Spooler
I have 3 printers attached to a server. From one of the printer I want to delete all the jobs from print spooler from windows 2000. I tried printer.killdoc. I couln't succeed.

Could you please let me know how can I delete all the jobs.

cud u reply to my query...im in urgent need of this concept

Rgds,
Rajeswari

EMF Spool File (multipage Emf) ?
Does anyone know how to create a multi-page EMF file?

Even an EMFSpool file would be fine.

I know how to use CreateEnhMetaFile, but I do not know how to make an EMF file with multiple pages.

Thanks.

Printer Spool Editor
Hey guys, a few years back i downloaded a visual basic program that allowed you to delete spooled printer documents all in the one source code.. None of the active x stuff of exe embedded into the printer drivver. I didnt really need it then so of course i deleted it, all fool me because now i need it and cant find it again

i would be very greatfull if any one has this source code or if you have something like it.

Thanks a bunch

Printer Spool Monitor
I'm designing an application that has to monitor and control installed printers so to be able to cancel printing jobs that are not authorized to print. This app is part of a program for my internet cafe. Doing research for this I found this VB project that monitors the printer spool but I'm having a lot of trouble to understand how it works as beside the spool watch the program use comunication between two processes, can someone help me to convert it to a bare bone printer watcher ? Or at least to understand how to do it myself ? Any help on the matter greatly appreciated as I'm stuck in this since a few days .
I attached the VB proyect printwatchserver.zip

Spool File Reader
Hi,

Can you help me out to read a Spool file (spl file) through a VB6 coding. EMFSpoolReader is for .Net but i couldnt get it for VB6. If you can get a dll for VB6 that is greatful.

Thanks,
Felix

Creating A Spool File
Hi,
How do you create a spool file in VB, which can be printed later by just copying it to the printer. My customer does not want to send any information to his users not in a form other than a spooled file so that the data cannot be tampered by an ordinary user. The user can only print the received file which will be in the desired format.

I think depends on the Printer driver the spool file format too vary.

Any help?
Thanx in advance

Huge Spool File...
I'm printing multi page tiff images using the Eastman Kodak controls (www.eastmansoftware.com). The spool files being sent to the printer are getting as large as 50+megs sometimes. It's causing a problem b/c the spool files are being send over a distance along a network. Are there any better/faster ways to print these files or any other ideas on speeding it up?

Thanks

How Do We Know The State Of The Spool Impression?
Hello.

How Do we know the state of the spool impression?,
if there is a printed document or it already finish printing.


Greetings

Dennis.


Printing Spool Files In DOS
I create report in simple spool file. i print this file using shell as following


Open "c: allybrd.rpt" for Output as #1
print #1, "| Uncalendered Calendered Bleached Dyed or Finished . |"
print #1, Chr(12)
Close #1
Shell "Notepad c: allybrd.rpt", vbMaximizedFocus

outf = FreeFile()
Open "C:prt.bat" for Output as #outf
print #outf, "cd"
print #outf, "type c: allybrd.rpt &gt; prn"
print #outf, "exit"
Close #outf
ret = Shell("c:prt.bat", vbHide)




This method created session in taskbar and that is not get killed. After printing five times if I see the taskbar window it show "winoldap" five times. Can anyone show me right method to print documents in dos mode.

Printer Spool Never Release
I have install a printer driver installed(generic) on my machine and shared it. So what happens is that another machine across the network sends the print out to my machine by mapping to my printer driver. The problem is sometimes when the other machine sends to my printer spool, the documents stay and not released... over a period of time it's starts to stack and I'll have quite a number there. The only way to solve this is by restarting...

Can i write a vb code to avoid the document printout to release from the spool

thanks

Cheers

Create Large Spool File
I'm trying to print multiple TIFF images but so far have only been able to print an individual image at a time. It's critical that I print all images together. Is there a way to create one single spool file for all of my images or something similar?

Thanks.

Monitoring Network Printer Spool
Hi,



I have a requirement to prevent the user from printing not more than
five reports in an hour. The same user can use different machine.



So, I have to monitor the printer spool to get the number of prints
given by the user.





Please share the logic for this.



Regards,

Subbu S



This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged
information.
If you are not the intended recipient, please contact the sender by reply
e-mail and destroy all copies of the original message.
Any unauthorized review, use, disclosure, dissemination, forwarding,
printing or copying of this email or any action taken in reliance on this
e-mail is strictly
prohibited and may be unlawful.

How To Check And Control Printer Spool
Hi, sorry for my english
   how I can read, lock and delete the printer spool?

Not from my application but from any application ex: from Internet Explorer or other

I have see the source code of "Printer Spool Monitor" but I can't lock or delete the processes... how to make this???

Thanks!!!
------------------------------------
Salve a tutti,
    come posso leggere, bloccare e cancellare lo spool di stampa?

Non stampe generate dalla mia applicazione ma, per esempio, da Internet Explorer o altre.
Ho già visto il codice di "Printer Spool Monitor" ma non mostra come bloccare o eliminare i vari processi prima che vengano stampati.... come posso fare???
Grazie!!!

Spool Output To The Text File
Hello everybody,


Please solve my problem. I just want to know how to generate a report through coding and to spool the result of the output to the text file.

Printing Directly To LPT3 To Spool To Network Printer
I'm using the following code and getting a overflow 6 error.


VB Code:
Dim Port As String, CTempLen As Long, CTemp As StringCTemp = Text3.TextCTempLen = Len(CTemp)Port = "LPT3:"Open Port For Output As #1 Len = CTempLenPrint #1, CTempClose #1


If I remove the Len = CTempLen it dosn't process.

Why would this happen?

How To Delete More Than One File Using Internet Control From A FTP Site.( Like Deltree Or Delete *.*
How to delete more than one file using internet control from a FTP site.( like deltree or delete *.*)

DELETE PROBLEM - Cannot DELETE After ADDing New Record Or UPDATING ?
Have a small problem here...very minor but a pain nonetheless.

Is anyone aware of any issues that would cause this problem:

If I open my form, browse through my records, and select a record to delete, and press Delete, it deletes no problem.


I can add a record, and it Inserts Into a table. If I press delete directly after, it will not delete. No error, no delete either.
or
I can update a record successfully. If I press delete directly after this, it will not delete either. Again no error, no delete either.


If I unload the form, and then reload the form again (Exit the form and re-open), I can delete the record fine.


Does anyone know what would be causing this issue?

PS - Its nothing to do with Locking/Enabling buttons etc. I checked that already. The delete button is fully enabled and unlocked ready for use.

Copyright 2005-08 www.BigResource.com, All rights reserved