How to programmatically delete a job

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone point me to an example of how you can programmatically delete a
specified print job?
 
Start>Control Panel>Printers and Faxes>doubleclick your printer>
If you want all printing to stop, click Printer and then click "cancel all
documents", or within that window, highlight the specific job and
click Document and click Cancel.
 
Hi Dan,

try this

Dieter

// Delete Job with Id nJobId

OSVERSIONINFO osInfo;
BOOL bResult;
HANDLE hPrinter = NULL;

if (!OpenPrinter (pPrinterName, &hPrinter, NULL))
{
...
}
ZeroMemory (&osInfo, sizeof (OSVERSIONINFO));
osInfo.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO);

GetVersionEx (&osInfo);

if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
osInfo.dwMajorVersion < 4)
{
// Windows 95/98/Me, Windows NT 3.51 and earlier
bResult = SetJob (hPrinter, nJobId, 0, NULL, JOB_CONTROL_CANCEL);
}
else
{
// Windows NT4.0 and later
bResult = SetJob (hPrinter, nJobId, 0, NULL, JOB_CONTROL_DELETE);
}
if (hPrinter)
{
ClosePrinter (hPrinter);
hPrinter = NULL;
}
 
Back
Top