Get paper size of Job print in StartDocPort

Hi.
I want to know the paper size and resolution selected by user for the
print job from StartDocPort function.

this is a StartDocPort function prototype:

BOOL WINAPI MyStartDocPort(
HANDLE hPort,
LPWSTR pPrinterName,
DWORD JobId,
DWORD Level,
LPBYTE pDocInfo)

due to it i have the printer, the port and the JobId
I have used it:

// obtain the DEVMODE struct witch have dmPaperLength and dmPaperWidth
fileds.

HANDLE hPrinter; // printer handle
JOB_INFO_2 JobInfo; // JobInfo2 Structure
DWORD dwNeeded; // bytes needed, if GetJob fails

// get printer handle
if (OpenPrinter(pPrinterName, &hPrinter, NULL))
{
// get JOB_INFO_2 structure.
if (GetJob(hPrinter, JobId, 2, (PBYTE)&JobInfo,
sizeof(JOB_INFO_2),&dwNeeded))
{
// set de DEVMODE struct.
CopyMemory(&pPort->DevMode, (JobInfo.pDevMode), sizeof(DEVMODE));
}
else
{
LeaveCritSection();
return FALSE;
}
}

but GetJob Call fails and return FALSE.

Any Ideas?

thanks in advance.

tolemaC / eleriumcore & unknownproductions
xxxxx@ono.com

What error code does GetJob fail with? You may have to pass
PRINTER_ACCESS_ADMINISTER or PRINTER_ALL_ACCESS. The failure could also
be occuring due to GetJob being called from the wrong process context.

  • Ashwin

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: tolemaC [mailto:xxxxx@ono.com]
Sent: Wednesday, May 29, 2002 4:09 PM
To: NT Developers Interest List
Subject: [ntdev] Get paper size of Job print in StartDocPort

Hi.
I want to know the paper size and resolution selected by user for the
print job from StartDocPort function.

this is a StartDocPort function prototype:

BOOL WINAPI MyStartDocPort(
HANDLE hPort,
LPWSTR pPrinterName,
DWORD JobId,
DWORD Level,
LPBYTE pDocInfo)

due to it i have the printer, the port and the JobId
I have used it:

// obtain the DEVMODE struct witch have dmPaperLength and dmPaperWidth
fileds.

HANDLE hPrinter; // printer handle
JOB_INFO_2 JobInfo; // JobInfo2 Structure
DWORD dwNeeded; // bytes needed, if GetJob fails

// get printer handle
if (OpenPrinter(pPrinterName, &hPrinter, NULL))
{
// get JOB_INFO_2 structure.
if (GetJob(hPrinter, JobId, 2, (PBYTE)&JobInfo,
sizeof(JOB_INFO_2),&dwNeeded))
{
// set de DEVMODE struct.
CopyMemory(&pPort->DevMode, (JobInfo.pDevMode), sizeof(DEVMODE));
}
else
{
LeaveCritSection();
return FALSE;
}
}

but GetJob Call fails and return FALSE.

Any Ideas?

thanks in advance.

tolemaC / eleriumcore & unknownproductions
xxxxx@ono.com


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%