OpenPrinter function __ Function

Source: Internet
Author: User


OpenPrinter function


The OpenPrinter function gets the identity handle of the specified printer or print server.

BOOL OpenPrinter (

LPTSTR pPrinterName,//pointer to printer or server name
Lphandle Phprinter,//handle to printer or server
Lpprinter_defaults pdefault//pointer to printer default structure
);

Parameters

pPrinterName
Refers to a null-terminated string that specifies the name of the printer or print server.

Phprinter
Point to a variable to receive a handle that identifies an open printer or print server object.

Pdefault
Point to a printer_defaults structure. This value can be empty.


return value

If the function succeeds, the return value is Non-zero.
If the function fails, the return value is zero. To get an extended error message, call the GetLastError function.

Note

The Pdefault parameter allows an application
To specify the data type and device mode values for the StartDocPrinter function to submit the printed document. However, once the file has been started,
These values can be overridden (overwritten) using the Setjob function.

Printer_defaults one of the data structure members desiredaccess, pointing to the OpenPrinter handle permission specified by Pdefault.
If the application wants to open a printer to perform administrative tasks.
For example, the SetPrinter function should turn on the printer and printer_all_access permissions.
If an application only performs a basic print business, the printer_access_use is sufficient.

Desiredaccess member Printer_defaults was ignored in Windows 95:openprinter.

The application can determine what permissions the customer has on the print server, or get a print server handle to invoke Waitforprinterchange.
In this way, it should require that OpenPrinter and pprintername be set to the name of the server and that a service permission value, such as server_all_access, should be specified.
Members of the PRINTER_DEFAULTS structure Pdatatype and pDevMode should be set to null.
This handle may be passed to the ClosePrinter or Waitforprinterchange function after such a call.

If the user does not hold permission to open a specified printer or print server, the OpenPrinter call will fail with the expected license, and

GetLastError returns the value error_access_denied.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.