The OpenPrinter function retrieves a handle identifying the specified printer or print server.
BOOL OpenPrinter(
LPTSTR pPrinterName, |
// pointer to printer or server name |
LPHANDLE phPrinter, |
// pointer to printer or server handle |
LPPRINTER_DEFAULTS pDefault |
// pointer to printer defaults structure |
); |
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.
The pDefault parameter allows an application to specify the data type and device mode values that are used for printing documents submitted by the StartDocPrinter function. However, these values can be overridden by using the SetJob function once a document has been started.
The DesiredAccess member of the PRINTER_DEFAULTS data structure pointed to by pDefault specifies the accesses that an application wishes to perform using the handle returned by OpenPrinter. If an application wishes to open a printer to perform administrative tasks, such as the SetPrinter function, it should open the printer with PRINTER_ALL_ACCESS access. If an application wishes only to perform basic printing operations, an access value that includes PRINTER_ACCESS_USE is sufficient.
Windows 95: OpenPrinter ignores the DesiredAccess member of PRINTER_DEFAULTS.
An application can determine what permissions a client has on a print server, or obtain a handle to a print server. To do so, it should call OpenPrinter with pPrinterName set to the name of the server and should specify a server access mask value such as SERVER_ALL_ACCESS. The pDatatype and pDevMode members of the PRINTER_DEFAULTS data structure should be set to NULL. The handle returned by such a call may be passed to the ClosePrinter function.
If a user does not hold permission to open a specified printer or print server with the desired access, the OpenPrinter call will fail, and GetLastError will return the value ERROR_ACCESS_DENIED.
ClosePrinter, SetPrinter, StartDocPrinter, PRINTER_DEFAULTS
file: /Techref/os/win/api/win32/func/src/f66_5.htm, 4KB, , updated: 2000/4/7 12:19, local time: 2024/9/1 11:44,
18.191.215.138:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/techref/os/win/api/win32/func/src/f66_5.htm"> OpenPrinter</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.