网站首页  词典首页

请输入您要查询的函数:

 

术语 setprinter
释义 SetPrinter
语法:
BOOL SetPrinter(
__in HANDLE hPrinter,
__in DWORD Level,
__in LPBYTE pPrinter,
__in DWORD Command
);
SetPrinter功能
该SetPrinter函数设置为指定的打印机数据或设置通过暂停打印指定的打印机的状态,恢复印刷,或清除所有打印作业。
参数
hPrinter [in]
句柄到打印机。使用OpenPrinter,OpenPrinter2,或添加打印机函数检索打印机处理。
Level [in]
的数据类型到缓冲区的功能商店指向pPrinter。如果命令参数不等于零的程度参数必须为零。
此值可以是0,2,3,4,5,6,7,8,或9。
pPrinter [in]
一个缓冲区包含的数据为打印机,或含有由Command参数指定的命令信息的指针。在缓冲区中的数据类型取决于Level值。
LevelStructure
0If命令参数PRINTER_CONTROL_SET_STATUS,pPrinter必须包含一个DWORD值,它指定新的打印机的状态设置。对于可能的状态值的列表,看到PRINTER_INFO_2结构的状态成员。请注意,PRINTER_STATUS_PAUSED和PRINTER_STATUS_PENDING_DELETION是无效的状态值来设置。
如果级别为0但命令没有PRINTER_CONTROL_SET_STATUS参数,pPrinter必须为NULL。
甲PRINTER_INFO_2结构包含有关打印机的详细信息。
第3A PRINTER_INFO_3结构包含打印机的安全信息。
第4A PRINTER_INFO_4结构包含最小的打印机信息,包括打印机的名称,服务器名称,打印机是否是远程或本地。
5A条PRINTER_INFO_5结构包含打印机信息,如打印机属性和超时设置。
6A条PRINTER_INFO_6结构指定一个打印机的状态值。
第7A PRINTER_INFO_7结构。这一结构dwAction成员表示是否SetPrinter应公布,取消发布,重新发布,或更新目录服务打印机的数据。
8A条PRINTER_INFO_8结构指定全局默认打印机设置。
9A条PRINTER_INFO_9结构指定每个用户的默认打印机设置。
命令 [in]
由SetPrinter函数执行的行动。
如果不为零级参数,命令必须为零。在这种情况下,打印机保持目前的状态和功能的重新配置的打印机的Level和pPrinter参数指定数据。
如果是零级参数,命令可以是下列值之一来设置打印机的状态。
ValueMeaning
PRINTER_CONTROL_PAUSEPauses打印机。
PRINTER_CONTROL_PURGEDeletes所有打印在打印机工作。
PRINTER_CONTROL_RESUMEResumes暂停打印机。
PRINTER_CONTROL_SET_STATUSSets打印机状态。该pPrinter参数是一个DWORD,指定新的打印机状态的指针。
返回值
如果函数成功,返回值是一个非零值。
如果函数失败,返回值是零。
如果是7级和公布的行动失败,SetPrinter返回ERROR_IO_PENDING,试图完成在后台的行动。如果是7级和更新操作失败,SetPrinter返回ERROR_FILE_NOT_FOUND。
备注
您不能使用SetPrinter更改默认打印机。有关更多信息,请参见打印机的输出。
要修改当前的打印机设置,调用GetPrinter函数来检索到PRINTER_INFO_2结构,当前的设置修改,作为必要的结构的成员,然后调用SetPrinter。
该SetPrinter函数忽略pServerName,AveragePPM,状态和一个PRINTER_INFO_2结构cJobs成员。
暂停暂停安排一台打印机的打印机的所有打印作业,除了一个打印作业,可能是因为目前印刷。打印作业,可提交暂停打印机,但没有工作将安排在该打印机上打印,直到打印恢复。如果打印机被清除,该打印机的所有打印作业都将被删除,除了当前的打印作业。
如果您使用SetPrinter修改默认的打印机的DEVMODE结构(全局设置打印机默认),您必须先调用DocumentProperties函数来验证DEVMODE结构。
对于PRINTER_INFO_2和PRINTER_INFO_3结构包含一个指向安全描述符,函数可以只设置安全描述符的这些组件调用者是否有权修改。要设置特定的安全描述符组件,您必须指定必需的访问权限时,您调用OpenPrinter或OpenPrinter2函数来处理检索到打印机。下表显示的访问需要修改各个安全描述符组成部分的权利。
访问permissionSecurity描述组件
WRITE_OWNEROwner小学组
WRITE_DACDiscretionary访问控制列表(DACL)
ACCESS_SYSTEM_SECURITYSystem访问控制列表(SACL)
如果安全描述符包含一个组件,调用方不具有权限的修改,SetPrinter失败。一个安全描述这些组件,您不希望修改应该是NULL或不存在,适当。如果您不想要修改安全描述符,并调用带有PRINTER_INFO_2结构SetPrinter,设置该结构pSecurityDescriptor成员为NULL。
Internet连接防火墙(ICF)块默认打印机端口,而是对文件和打印共享例外可以启用。如果SetPrinter是由机具有管理员称,它使异常。如果它是由一个非管理员和例外呼吁还没有被启用,调用失败。
您可以使用与PRINTER_INFO_7结构7级发布,取消发布或更新的打印机目录服务数据。对于打印机目录服务的数据包括所有的数据存储在SPLDS_由打印机调用SetPrinterDataEx功能*键。在调用SetPrinter,设置PRINTER_INFO_7 pszObjectGUID成员为NULL并设置dwAction成员为下列值之一。
ValueDescription
DSPRINT_PUBLISHPublishes目录服务数据。
DSPRINT_REPUBLISHThe目录打印机的服务是未发表的数据,然后再公布,刷新在发布的打印机的所有属性。重新出版也改变了发布的打印机的GUID。使用此值,如果您怀疑打印机的公布的数据已被损坏。
DSPRINT_UNPUBLISHUnpublishes目录服务数据。
DSPRINT_UPDATEUpdates目录服务数据。这是相同的DSPRINT_PUBLISH,除了SetPrinter与ERROR_FILE_NOT_FOUND失败如果打印机不是已发布。
使用DSPRINT_UPDATE更新公布属性,但不能强迫出版。打印机驱动程序应始终使用DSPRINT_UPDATE而不是DSPRINT_PUBLISH。
DSPRINT_PENDING并非SetPrinter有效dwAction价值。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinspool.h(头文件:winuser.h)
LibraryWinspool.lib
DLLSpoolss.dll
Unicode和ANSI namesSetPrinterW(Unicode)和SetPrinterA(ANSI)的
参见
Printing and Print Spooler Overview
Printing and Print Spooler 函数
添加打印机
GetPrinter
OpenPrinter
OpenPrinter2
PRINTER_INFO_2
PRINTER_INFO_3
PRINTER_INFO_4
PRINTER_INFO_5
PRINTER_INFO_6
PRINTER_INFO_7
PRINTER_INFO_8
PRINTER_INFO_9
SetPrinterDataEx
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月11日
==英文原文==SetPrinter Function
The SetPrinter function sets the data for a specified printer or sets the state of the specified printer by pausing printing, resuming printing, or clearing all print jobs.
Syntax
BOOL SetPrinter(
__in HANDLE hPrinter,
__in DWORD Level,
__in LPBYTE pPrinter,
__in DWORD Command
);
Parameters
hPrinter [in]
A handle to the printer. Use the OpenPrinter , OpenPrinter2 , or AddPrinter function to retrieve a printer handle.
Level [in]
The type of data that the function stores into the buffer pointed to by pPrinter. If the Command parameter is not equal to zero, the Level parameter must be zero.
This value can be 0, 2, 3, 4, 5, 6, 7, 8, or 9.
pPrinter [in]
A pointer to a buffer containing data to set for the printer, or containing information for the command specified by the Command parameter. The type of data in the buffer is determined by the value of Level.
LevelStructure
0If the Command parameter is PRINTER_CONTROL_SET_STATUS, pPrinter must contain a DWORD value that specifies the new printer status to set. For a list of the possible status values, see the Status member of the PRINTER_INFO_2 structure. Note that PRINTER_STATUS_PAUSED and PRINTER_STATUS_PENDING_DELETION are not valid status values to set.
If Level is 0, but the Command parameter is not PRINTER_CONTROL_SET_STATUS, pPrinter must be NULL.
2A PRINTER_INFO_2 structure containing detailed information about the printer.
3A PRINTER_INFO_3 structure containing the printer's security information.
4A PRINTER_INFO_4 structure containing minimal printer information, including the name of the printer, the name of the server, and whether the printer is remote or local.
5A PRINTER_INFO_5 structure containing printer information such as printer attributes and time-out settings.
6A PRINTER_INFO_6 structure specifying the status value of a printer.
7A PRINTER_INFO_7 structure. The dwAction member of this structure indicates whether SetPrinter should publish, unpublish, re-publish, or update the printer's data in the directory service.
8A PRINTER_INFO_8 structure specifying the global default printer settings.
9A PRINTER_INFO_9 structure specifying the per-user default printer settings.

Command [in]
The action performed by the SetPrinter function.
If the Level parameter is nonzero, Command must be zero. In this case, the printer retains its current state and the function reconfigures the printer data as specified by the Level and pPrinter parameters.
If the Level parameter is zero, Command can be one of the following values to set the state of the printer.
ValueMeaning
PRINTER_CONTROL_PAUSEPauses the printer.
PRINTER_CONTROL_PURGEDeletes all print jobs in the printer.
PRINTER_CONTROL_RESUMEResumes a paused printer.
PRINTER_CONTROL_SET_STATUSSets the printer status. The pPrinter parameter is a pointer to a DWORD that specifies the new printer status.

Return Value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero.
If Level is 7 and the publish action failed, SetPrinter returns ERROR_IO_PENDING and attempts to complete the action in the background. If Level is 7 and the update action failed, SetPrinter returns ERROR_FILE_NOT_FOUND.
Remarks
You cannot use SetPrinter to change the default printer. For more information, see Printer Output .
To modify the current printer settings, call the GetPrinter function to retrieve the current settings into a PRINTER_INFO_2 structure, modify the members of that structure as necessary, and then call SetPrinter.
The SetPrinter function ignores the pServerName, AveragePPM, Status, and cJobs members of a PRINTER_INFO_2 structure.
Pausing a printer suspends scheduling of all print jobs for that printer, except for the one print job that may be currently printing. Print jobs can be submitted to a paused printer, but no jobs will be scheduled to print on that printer until printing is resumed. If a printer is cleared, all print jobs for that printer are deleted, except for the current print job.
If you use SetPrinter to modify the default DEVMODE structure for a printer (globally setting the printer defaults), you must first call the DocumentProperties function to validate the DEVMODE structure.
For the PRINTER_INFO_2 and PRINTER_INFO_3 structures that contain a pointer to a security descriptor, the function can set only those components of the security descriptor that the caller has permission to modify. To set particular security descriptor components, you must specify the necessary access rights when you call the OpenPrinter or OpenPrinter2 function to retrieve a handle to the printer. The following table shows the access rights required to modify the various security descriptor components.
Access permissionSecurity descriptor component
WRITE_OWNEROwner Primary group
WRITE_DACDiscretionary access-control list (DACL)
ACCESS_SYSTEM_SECURITYSystem access-control list (SACL)

If the security descriptor contains a component that the caller does not have the access right to modify, SetPrinter fails. Those components of a security descriptor that you don't want to modify should be NULL or not be present, as appropriate. If you do not want to modify the security descriptor, and are calling SetPrinter with a PRINTER_INFO_2 structure, set the pSecurityDescriptor member of that structure to NULL.
The Internet Connection Firewall (ICF) blocks printer ports by default, but an exception for File and Print Sharing can be enabled. If SetPrinter is called by a machine admin, it enables the exception. If it is called by a non-admin and the exception has not already been enabled, the call fails.
You can use level 7 with the PRINTER_INFO_7 structure to publish, unpublish, or update directory service data for the printer. The directory service data for a printer includes all the data stored under the SPLDS_* keys by calls to the SetPrinterDataEx function for the printer. Before calling SetPrinter, set the pszObjectGUID member of PRINTER_INFO_7 to NULL and set the dwAction member to one of the following values.
ValueDescription
DSPRINT_PUBLISHPublishes the directory service data.
DSPRINT_REPUBLISHThe directory service data for the printer is unpublished and then published again, refreshing all properties in the published printer. Re-publishing also changes the GUID of the published printer. Use this value if you suspect the printer's published data has been corrupted.
DSPRINT_UNPUBLISHUnpublishes the directory service data.
DSPRINT_UPDATEUpdates the directory service data. This is the same as DSPRINT_PUBLISH, except that SetPrinter fails with ERROR_FILE_NOT_FOUND if the printer is not already published.
Use DSPRINT_UPDATE to update published properties but not force publishing. Printer drivers should always use DSPRINT_UPDATE rather than DSPRINT_PUBLISH.

DSPRINT_PENDING is not a valid dwAction value for SetPrinter.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinspool.h (include Windows.h)
LibraryWinspool.lib
DLLSpoolss.dll
Unicode and ANSI namesSetPrinterW (Unicode) and SetPrinterA (ANSI)
See Also
Printing and Print Spooler Overview
Printing and Print Spooler Functions
AddPrinter
GetPrinter
OpenPrinter
OpenPrinter2
PRINTER_INFO_2
PRINTER_INFO_3
PRINTER_INFO_4
PRINTER_INFO_5
PRINTER_INFO_6
PRINTER_INFO_7
PRINTER_INFO_8
PRINTER_INFO_9
SetPrinterDataEx
Send comments about this topic to Microsoft
Build date: 7/11/2009
==原始网址==http://msdn.microsoft.com/en-us/library/dd145082(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:24:22