vc++ AddJob fails from XP

  • Thread starter Thread starter Stewart Peck
  • Start date Start date
S

Stewart Peck

I can't get it to accept a buffer and it won't tell me how
large of a buffer it wants. Has anyone run into this error
yet?

Thanks
 
Stewart Peck said:
I can't get it to accept a buffer and it won't tell me how
large of a buffer it wants. Has anyone run into this error
yet?

Thanks

I think you should be posting this to one of the visual c++ groups rather
than general support. Say which version of windows you're testing on and
post a sample of your code so someone can see if you're doing it properly.


The ADDJOB_INFO_1 structure identifies a print job as well as the directory
and file in which an application can store that job.

typedef struct _ADDJOB_INFO_1 { // aji1
LPTSTR Path;
DWORD JobId;
} ADDJOB_INFO_1;


Members

Path

Points to a null-terminated string that contains the path and filename that
the application can use to store the print job.

JobId

Identifies the print job.

AddJob
The AddJob function obtains a path string that specifies a file that you can
use to store a spooled print job.

BOOL AddJob(

HANDLE hPrinter, // specifies printer for the print job
DWORD Level, // specifies version of print job information data
structure
LPBYTE pData, // pointer to buffer to receive print job information data
DWORD cbBuf, // specifies size of buffer pointed to by pData
LPDWORD pcbNeeded // pointer to variable to receive size of print job
information data
);


Parameters

hPrinter

Handle that specifies the printer for the print job. This must be a local
printer that is configured as a spooled printer. If hPrinter is a handle to
a remote printer connection, or if the printer is configured for direct
printing, the AddJob function fails.

Level

Specifies the version of the print job information data structure that the
function stores into the buffer pointed to by pData. Set this parameter to
one.

pData

Pointer to a buffer to receive an ADDJOB_INFO_1 data structure and a path
string.

cbBuf

Specifies the size, in bytes, of the buffer pointed to by pData. The buffer
needs to be large enough to contain an ADDJOB_INFO_1 structure and a path
string.

pcbNeeded

Pointer to a variable to receive the total size, in bytes, of the
ADDJOB_INFO_1 data structure plus the path string. If this value is less
than or equal to cbBuf and the function succeeds, this is the actual number
of bytes written to the buffer pointed to by pData. If this number is
greater than cbBuf, the buffer is too small, and you must call the function
again with a buffer size at least as large as *pcbNeeded.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error
information, call GetLastError.

Remarks

You can call the CreateFile function to open the spool file specified by the
Path member of the ADDJOB_INFO_1 structure, and then call the WriteFile
function to write print job data to it. Once that is done, call ScheduleJob
to notify the print spooler that the print job can now be scheduled by the
spooler for printing.
 
Back
Top