RB said:
But you can stop it via control panel (I think I did once), so why
can't this be done in VB?
Well, yeah, you can always *try* to pull an Abort on it, sure. But as I said, if the
pages are already spitting, the odds are that most/all of the bits have already
spooled. To get an idea of how to send an Abort, see
http://vb.mvps.org/samples/PrnInfo -- in particular, the following methods of the
CPrinterJobs class:
Public Function ControlCancel(ByVal JobId As Long) As Boolean
Dim os As OSVERSIONINFO
' NT4 is the dividing line between two different
' control codes for this call.
os.dwOSVersionInfoSize = Len(os)
Call GetVersionEx(os)
' Attempt to cancel passed job.
If os.dwPlatformId = VER_PLATFORM_WIN32_NT And os.dwMajorVersion >= 4 Then
ControlCancel = SendControl(JobId, jcDelete)
Else
ControlCancel = SendControl(JobId, jcCancel)
End If
End Function
Private Function SendControl(ByVal JobId As Long, ByVal ControlCode As
JobControlCodes) As Boolean
Dim hPrn As Long
' Get handle to printer.
Call OpenPrinter(m_DevName, hPrn, ByVal 0&)
If hPrn Then
' Send requested control code.
SendControl = CBool(SetJob(hPrn, JobId, 0, ByVal 0&, ControlCode))
Call ClosePrinter(hPrn)
' Update all object data.
Call Me.Refresh
End If
End Function
That will, at least, stop Windows from sending any more bits down the wire. What's
already in the printer's internal buffer is out of reach, however.
Good luck... Karl