网站首页  词典首页

请输入您要查询的函数:

 

术语 openprinter
释义 OpenPrinter
语法:
BOOL OpenPrinter(
__in LPTSTR pPrinterName,
__out LPHANDLE phPrinter,
__in LPPRINTER_DEFAULTS pDefault
);
OpenPrinter函数
该OpenPrinter函数检索的句柄指定的打印机或打印服务器或其他类型的打印子系统处理。
参数
pPrinterName [in]
一个指向 null 结尾的字符串指针,指定的打印机或打印服务器的名称,打印机对象,XcvMonitor,或XcvPort。
对于打印机对象使用:PrinterName的,工作XXXX的。对于XcvMonitor,使用:服务器,XcvMonitor MonitorName。对于XcvPort,使用:服务器,XcvPort端口名。
如果为NULL,则表示本地打印机服务器。
phPrinter [out]
一个变量,它接收处理指针(不是线程安全),以开放的打印机或打印服务器对象。
该phPrinter参数可以返回Xcv处理与XcvData功能的使用。欲了解更多有关XcvData信息,请参阅DDK中。
pDefault [in]
一个 PRINTER_DEFAULTS结构的指针。此值可以为NULL。
返回值
如果函数成功,返回值是一个非零值。
如果函数失败,返回值是零。
备注
不要在DllMain中调用此方法。
句柄指向phPrinter不是线程安全的。如来电者需要使用多线程是同时,他们必须提供自定义的打印机使用的同步处理功能的同步访问。为了避免编写自定义代码的应用程序可以打开打印机每个线程处理,根据需要。
该pDefault参数使您可以指定数据类型和设备模式是由印刷StartDocPrinter函数提交文件所使用的值。但是,您也可以通过使用SetJob函数的文档后,这些价值观已经启动。
的DEVMODE在pDefault参数PRINTER_DEFAULTS结构定义的设置不使用时,StartPrintDocpDocInfo参数DOC_INFO_1 pDatatype是“原始”。当一个高层次的文件(如Adobe PDF或Microsoft Word文件)或其他打印机的数据(如氯化磷,聚苯乙烯,或HPGL)直接发送到设置为“原始”pDatatype打印机时,文件必须充分描述DEVMODE的风格打印由硬件理解的语言项目的设置。
您可以调用OpenPrinter函数打开的句柄打印服务器或确定的访问权限,一个客户端已到打印服务器。为此,指定在pPrinterName参数打印服务器的名称,设置PRINTER_DEFAULTS结构pDatatype和pDevMode成员为NULL,并设置DesiredAccess成员指定诸如SERVER_ALL_ACCESS服务器访问掩码值。当您完成与处理,将它传递给ClosePrinter函数将其关闭。
使用该PRINTER_DEFAULTS结构DesiredAccess成员指定访问权限,您需要到打印机。访问权限可以是下列之一。 (如果pDefault为NULL,则访问权限PRINTER_ACCESS_USE。)
期望访问valueMeaning
PRINTER_ACCESS_ADMINISTERTo执行如SetPrinter提供的,行政任务。
PRINTER_ACCESS_USETo执行基本印刷业务。
PRINTER_ALL_ACCESSTo执行所有的管理任务,除了同步和基本印刷业务(见标准访问权限。
一般的安全值,如WRITE_DACTo允许特定的控制访问权限。见标准访问权限。
如果用户没有权限开启所需的访问指定的打印机或打印服务器,OpenPrinter调用将失败,并为零,而且GetLastError将返回值返回值ERROR_ACCESS_DENIED。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinspool.h(头文件:winuser.h)
LibraryWinspool.lib
DLLSpoolss.dll
Unicode和ANSI namesOpenPrinterW(Unicode)和OpenPrinterA(ANSI)的
参见
Printing and Print Spooler Overview
Printing and Print Spooler 函数
WritePrinter
ClosePrinter
PRINTER_DEFAULTS
SetJob
SetPrinter
StartDocPrinter
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月11日
==英文原文==OpenPrinter Function
The OpenPrinter function retrieves a handle to the specified printer or print server or other types of handles in the print subsystem.
Syntax
BOOL OpenPrinter(
__in LPTSTR pPrinterName,
__out LPHANDLE phPrinter,
__in LPPRINTER_DEFAULTS pDefault
);
Parameters
pPrinterName [in]
A pointer to a null-terminated string that specifies the name of the printer or print server, the printer object, the XcvMonitor, or the XcvPort.
For a printer object use: PrinterName, Job xxxx. For an XcvMonitor, use: ServerName, XcvMonitor MonitorName. For an XcvPort, use: ServerName, XcvPort PortName.
If NULL, it indicates the local printer server.
phPrinter [out]
A pointer to a variable that receives a handle (not thread safe) to the open printer or print server object.
The phPrinter parameter can return an Xcv handle for use with the XcvData function. For more information about XcvData, see the DDK.
pDefault [in]
A pointer to a PRINTER_DEFAULTS structure. This value can be NULL.
Return Value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero.
Remarks
Do not call this method in DllMain .
The handle pointed to by phPrinter is not thread safe. If callers need to use it concurrently on multiple threads, they must provide custom synchronization access to the printer handle using the Synchronization Functions . To avoid writing custom code the application can open a printer handle on each thread, as needed.
The pDefault parameter enables you to specify the data type and device mode values that are used for printing documents submitted by the StartDocPrinter function. However, you can override these values by using the SetJob function after a document has been started.
The DEVMODE settings defined in the PRINTER_DEFAULTS structure of the pDefault parameter are not used when the StartPrintDocpDocInfo parameter DOC_INFO_1 pDatatype is "RAW". When a high-level document (such as an Adobe PDF or Microsoft Word file) or other printer data (such PCL, PS, or HPGL) is sent directly to a printer with pDatatype set to "RAW", the document must fully describe the DEVMODE-style print job settings in the language understood by the hardware.
You can call the OpenPrinter function to open a handle to a print server or to determine the access rights that a client has to a print server. To do so, specify the name of the print server in the pPrinterName parameter, set the pDatatype and pDevMode members of the PRINTER_DEFAULTS structure to NULL, and set the DesiredAccess member to specify a server access mask value such as SERVER_ALL_ACCESS. When you are finished with the handle, pass it to the ClosePrinter function to close it.
Use the DesiredAccess member of the PRINTER_DEFAULTS structure to specify the access rights that you need to the printer. The access rights can be one of the following. (If pDefault is NULL, then the access rights are PRINTER_ACCESS_USE.)
Desired Access valueMeaning
PRINTER_ACCESS_ADMINISTERTo perform administrative tasks, such as those provided by SetPrinter .
PRINTER_ACCESS_USETo perform basic printing operations.
PRINTER_ALL_ACCESSTo perform all administrative tasks and basic printing operations except for SYNCHRONIZE (see Standard Access Rights .
generic security values, such as WRITE_DACTo allow specific control access rights. See Standard Access Rights .

If a user does not have permission to open a specified printer or print server with the desired access, the OpenPrinter call will fail with a return value of zero and GetLastError will return the value ERROR_ACCESS_DENIED.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinspool.h (include Windows.h)
LibraryWinspool.lib
DLLSpoolss.dll
Unicode and ANSI namesOpenPrinterW (Unicode) and OpenPrinterA (ANSI)
See Also
Printing and Print Spooler Overview
Printing and Print Spooler Functions
WritePrinter
ClosePrinter
PRINTER_DEFAULTS
SetJob
SetPrinter
StartDocPrinter
Send comments about this topic to Microsoft
Build date: 7/11/2009
==原始网址==http://msdn.microsoft.com/en-us/library/dd162751(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:17:28