网站首页  词典首页

请输入您要查询的函数:

 

术语 enumprinters
释义 EnumPrinters
语法:
BOOL EnumPrinters(
__in DWORD Flags,
__in LPTSTR Name,
__in DWORD Level,
__out LPBYTE pPrinterEnum,
__in DWORD cbBuf,
__out LPDWORD pcbNeeded,
__out LPDWORD pcReturned
);
EnumPrinters函数
该EnumPrinters函数枚举可用打印机,打印服务器,域或印刷商。
参数
标志 [in]
印刷对象的类型的函数应该枚举。该值可以是一个或多个下列值。
ValueMeaning
PRINTER_ENUM_LOCALIf的PRINTER_ENUM_NAME标志也没有通过,函数忽略Name参数,并列举了本地安装的打印机。如果PRINTER_ENUM_NAME亦获通过,该函数枚举名称的本地打印机。
PRINTER_ENUM_NAMEThe function enumerates the printer identified by Name.这可以是一个服务器,域,或打印提供商。如果名称为NULL,则函数枚举提供印刷服务供应商。
PRINTER_ENUM_SHAREDThe函数枚举打印机都有共同的属性。不能孤立地使用,使用或操作结合起来,另一PRINTER_ENUM类型。
PRINTER_ENUM_CONNECTIONSThe函数枚举打印机的列表,用户以前的连接了。
PRINTER_ENUM_NETWORKThe函数枚举计算机的网域网络打印机。此值才有效,如果是1级。
PRINTER_ENUM_REMOTEThe函数枚举计算机的网域网络打印机和打印服务器。此值才有效,如果是1级。
如果是4级,您只能使用PRINTER_ENUM_CONNECTIONS和PRINTER_ENUM_LOCAL常数。
名称 [in]
如果是1级,旗包含PRINTER_ENUM_NAME,和名称是非空,然后将其命名是对一个空指针结尾的字符串,它指定对象的名称来枚举。该字符串可以是一个服务器,域,或打印提供者的名称。
如果是1级,旗包含PRINTER_ENUM_NAME,和名称为NULL,则函数枚举可用的印刷服务供应商。
如果是1级,旗包含PRINTER_ENUM_REMOTE,和名称为NULL,则函数枚举用户的域的打印机。
如果是2级或5,名称是对一个空指针结尾的字符串,指定了服务器的打印机的名称一一列举。如果该字符串为NULL,则函数枚举本地计算机上安装的打印机。
如果是4级,名称应为NULL。查询的函数总是在本地计算机上。
当名称为NULL,设置标志,以PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS列举打印机在本地计算机上安装。这些打印机包括那些在物理上连接到本地计算机以及它有一个网络连接的远程打印机。
当名称不为NULL,设置标志,以PRINTER_ENUM_LOCAL | PRINTER_ENUM_NAME列举了在服务器上安装本地打印机名称。
Level [in]
数据结构类型指向pPrinterEnum。有效值为1,2,4和5,它们对应的PRINTER_INFO_1,PRINTER_INFO_2,PRINTER_INFO_4和PRINTER_INFO_5数据结构。
此值可以是1,2,4或5。
pPrinterEnum [out]
A到接收缓冲区的PRINTER_INFO_1,PRINTER_INFO_2,PRINTER_INFO_4,或PRINTER_INFO_5结构数组的指针。每个结构包含的数据描述了可用的打印对象。
如果级别是1,数组包含PRINTER_INFO_1结构。如果是2级的数组包含PRINTER_INFO_2结构。如果是4级的数组包含PRINTER_INFO_4结构。如果是5级的数组包含PRINTER_INFO_5结构。
该缓冲区必须足够大,接收的数据结构和任何条件或其他数据数组成员的结构问题。如果缓冲区太小,pcbNeeded参数返回所需的缓冲区大小。
cbBuf [in]
大小,指出以字节为缓冲区的pPrinterEnum。
pcbNeeded [out]
一个值,接收复制的字节数,如果函数调用成功或所需的字节数指针,如果cbBuf太小。
pcReturned [out]
一个值,接收的PRINTER_INFO_1,PRINTER_INFO_2,PRINTER_INFO_4,或PRINTER_INFO_5数量结构指针,数组中的函数返回的pPrinterEnum点。
返回值
如果函数成功,返回值是一个非零值。
如果函数失败,返回值是零。
备注
不要在DllMain中调用此方法。
如果EnumPrinters返回PRINTER_INFO_1结构,使PRINTER_ENUM_CONTAINER指定,这表明有一个打印机对象的层次结构。应用程序可以通过调用EnumPrinters枚举再次层次,设置名称向PRINTER_INFO_1结构的pName成员的值。
该EnumPrinters函数不检索的安全信息。如果结构数组中的retuPRINTER_INFO_2rned指向pPrinterEnum,其pSecurityDescriptor成员将设置为NULL。
要获得有关默认打印机的信息,请与板块名称设置为“窗口字符串GetProfileString函数”,关键名称字符串设置为“设备”。返回的字符串包含默认的打印机名称,打印机的越南民主共和国的文件名,以及这种打印机连接端口。
要获得有关默认打印机的信息,请拨打GetDefaultPrinter
该PRINTER_INFO_4结构提供了一种简单,非常快速的方法来检索本地计算机上安装的打印机的名称,以及一个用户建立远程连接。当EnumPrinters是与PRINTER_INFO_4数据结构,该函数查询指定的信息登记,然后立即返回。这不同于时与PRINTER_INFO_ *其他级别的数据结构称为EnumPrinters行为。特别是,当EnumPrinters与2级(PRINTER_INFO_2)数据结构,它执行对每个远程连接OpenPrinter调用。如果远程连接故障,或者远程服务器不再存在,或远程打印机不再存在,函数必须等待的RPC超时,因此失败OpenPrinter调用。这可能需要一段时间。传递一个PRINTER_INFO_4结构允许应用程序检索到所需的最低限度的信息,如果更详细的资料是需要的,随后EnumPrinters 2级呼叫可。
Windows Vista的:打印机的EnumPrinters返回的数据是来自本地缓存时Level值为4。
下表显示了各种标志EnumPrinters输出值时,级别参数设置为1。
在表名称参数列,您应该以一个打印提供商,域,机适当的名称。例如,对于“打印供应商”,您可以使用网络打印供应商或本地打印提供程序名称。要检索设置为NULL名称印刷者名称,电话EnumPrinters。
旗parameterName parameterResult
PRINTER_ENUM_LOCAL(而不是PRINTER_ENUM_NAME)name参数是ignored.All本地打印机。
PRINTER_ENUM_NAME“打印提供者”的所有域名
PRINTER_ENUM_NAME“打印专家!域”的所有打印机和计算机的域打印服务器
PRINTER_ENUM_NAME“打印提供商!\\ \\机器”,所有在\\共享打印机\\机
PRINTER_ENUM_NAMEAn空字符串“,”所有本地打印机。
在计算机的域PRINTER_ENUM_NAMENULLAll印刷商
PRINTER_ENUM_CONNECTIONSThe名称参数是ignored.All连接的远程打印机
PRINTER_ENUM_NETWORKTheName参数是在计算机的域ignored.All打印机
PRINTER_ENUM_REMOTEAn空字符串“,”所有的打印机和打印服务器在计算机的域
PRINTER_ENUM_REMOTE“打印提供者”相同PRINTER_ENUM_NAME
PRINTER_ENUM_REMOTE“打印专家!域”的所有打印机和计算机的域打印服务器,无论指定的网域。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinspool.h(头文件:winuser.h)
LibraryWinspool.lib
DLLSpoolss.dll
Unicode和ANSI namesEnumPrintersW(Unicode)和EnumPrintersA(ANSI)的
参见
Printing and Print Spooler Overview
Printing and Print Spooler 函数
添加打印机
DeletePrinter
GetPrinter
PRINTER_INFO_1
PRINTER_INFO_2
PRINTER_INFO_4
PRINTER_INFO_5
SetPrinter
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月11日
==英文原文==EnumPrinters Function
The EnumPrinters function enumerates available printers, print servers, domains, or print providers.
Syntax
BOOL EnumPrinters(
__in DWORD Flags,
__in LPTSTR Name,
__in DWORD Level,
__out LPBYTE pPrinterEnum,
__in DWORD cbBuf,
__out LPDWORD pcbNeeded,
__out LPDWORD pcReturned
);
Parameters
Flags [in]
The types of print objects that the function should enumerate. This value can be one or more of the following values.
ValueMeaning
PRINTER_ENUM_LOCALIf the PRINTER_ENUM_NAME flag is not also passed, the function ignores the Name parameter, and enumerates the locally installed printers. If PRINTER_ENUM_NAME is also passed, the function enumerates the local printers on Name.
PRINTER_ENUM_NAMEThe function enumerates the printer identified by Name. This can be a server, a domain, or a print provider. If Name is NULL, the function enumerates available print providers.
PRINTER_ENUM_SHAREDThe function enumerates printers that have the shared attribute. Cannot be used in isolation; use an OR operation to combine with another PRINTER_ENUM type.
PRINTER_ENUM_CONNECTIONSThe function enumerates the list of printers to which the user has made previous connections.
PRINTER_ENUM_NETWORKThe function enumerates network printers in the computer's domain. This value is valid only if Level is 1.
PRINTER_ENUM_REMOTEThe function enumerates network printers and print servers in the computer's domain. This value is valid only if Level is 1.

If Level is 4, you can only use the PRINTER_ENUM_CONNECTIONS and PRINTER_ENUM_LOCAL constants.
Name [in]
If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is non-NULL, then Name is a pointer to a null-terminated string that specifies the name of the object to enumerate. This string can be the name of a server, a domain, or a print provider.
If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is NULL, then the function enumerates the available print providers.
If Level is 1, Flags contains PRINTER_ENUM_REMOTE, and Name is NULL, then the function enumerates the printers in the user's domain.
If Level is 2 or 5,Name is a pointer to a null-terminated string that specifies the name of a server whose printers are to be enumerated. If this string is NULL, then the function enumerates the printers installed on the local computer.
If Level is 4, Name should be NULL. The function always queries on the local computer.
When Name is NULL, setting Flags to PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS enumerates printers that are installed on the local machine. These printers include those that are physically attached to the local machine as well as remote printers to which it has a network connection.
When Name is not NULL, setting Flags to PRINTER_ENUM_LOCAL | PRINTER_ENUM_NAME enumerates the local printers that are installed on the server Name.
Level [in]
The type of data structures pointed to by pPrinterEnum. Valid values are 1, 2, 4, and 5, which correspond to the PRINTER_INFO_1 , PRINTER_INFO_2 , PRINTER_INFO_4 , and PRINTER_INFO_5 data structures.
This value can be 1, 2, 4, or 5.
pPrinterEnum [out]
A pointer to a buffer that receives an array of PRINTER_INFO_1, PRINTER_INFO_2, PRINTER_INFO_4, or PRINTER_INFO_5 structures. Each structure contains data that describes an available print object.
If Level is 1, the array contains PRINTER_INFO_1 structures. If Level is 2, the array contains PRINTER_INFO_2 structures. If Level is 4, the array contains PRINTER_INFO_4 structures. If Level is 5, the array contains PRINTER_INFO_5 structures.
The buffer must be large enough to receive the array of data structures and any strings or other data to which the structure members point. If the buffer is too small, the pcbNeeded parameter returns the required buffer size.
cbBuf [in]
The size, in bytes, of the buffer pointed to by pPrinterEnum.
pcbNeeded [out]
A pointer to a value that receives the number of bytes copied if the function succeeds or the number of bytes required if cbBuf is too small.
pcReturned [out]
A pointer to a value that receives the number of PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, or PRINTER_INFO_5 structures that the function returns in the array to which pPrinterEnum points.
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 .
If EnumPrinters returns a PRINTER_INFO_1 structure in which PRINTER_ENUM_CONTAINER is specified, this indicates that there is a hierarchy of printer objects. An application can enumerate the hierarchy by calling EnumPrinters again, setting Name to the value of the PRINTER_INFO_1 structure's pName member.
The EnumPrinters function does not retrieve security information. If structures are retuPRINTER_INFO_2rned in the array pointed to by pPrinterEnum, their pSecurityDescriptor members will be set to NULL.
To get information about the default printer, call the GetProfileString function with the section name string set to "windows" and the key name string set to "device". The returned string contains the name of the default printer, the name of the printer DRV file, and the port to which the printer is attached.
To get information about the default printer, call GetDefaultPrinter
The PRINTER_INFO_4 structure provides an easy and extremely fast way to retrieve the names of the printers installed on a local machine, as well as the remote connections that a user has established. When EnumPrinters is called with a PRINTER_INFO_4 data structure, that function queries the registry for the specified information, then returns immediately. This differs from the behavior of EnumPrinters when called with other levels of PRINTER_INFO_* data structures. In particular, when EnumPrinters is called with a level 2 ( PRINTER_INFO_2 ) data structure, it performs an OpenPrinter call on each remote connection. If a remote connection is down, or the remote server no longer exists, or the remote printer no longer exists, the function must wait for RPC to time out and consequently fail the OpenPrinter call. This can take a while. Passing a PRINTER_INFO_4 structure lets an application retrieve a bare minimum of required information; if more detailed information is desired, a subsequent EnumPrinters level 2 call can be made.
Windows Vista: The printer data returned by EnumPrinters is retrieved from a local cache when the value of Level is 4.
The following table shows the EnumPrinters output for various Flags values when the Level parameter is set to 1.
In the Name parameter column of the table, you should substitute an appropriate name for Print Provider, Domain, and Machine. For example, for "Print Provider," you could use the name of the network print provider or the name of the local print provider. To retrieve print provider names, call EnumPrinters with Name set to NULL.
Flags parameterName parameterResult
PRINTER_ENUM_LOCAL (and not PRINTER_ENUM_NAME)The Name parameter is ignored.All local printers.
PRINTER_ENUM_NAME"Print Provider"All domain names
PRINTER_ENUM_NAME"Print Provider!Domain"All printers and print servers in the computer's domain
PRINTER_ENUM_NAME"Print Provider!!\\\\Machine"All printers shared at \\\\Machine
PRINTER_ENUM_NAMEAn empty string, ""All local printers.
PRINTER_ENUM_NAMENULLAll print providers in the computer's domain
PRINTER_ENUM_CONNECTIONSThe Name parameter is ignored.All connected remote printers
PRINTER_ENUM_NETWORKTheName parameter is ignored.All printers in the computer's domain
PRINTER_ENUM_REMOTEAn empty string, ""All printers and print servers in the computer's domain
PRINTER_ENUM_REMOTE "Print Provider"Same as PRINTER_ENUM_NAME
PRINTER_ENUM_REMOTE"Print Provider!Domain"All printers and print servers in computer's domain, regardless of Domain specified.

Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinspool.h (include Windows.h)
LibraryWinspool.lib
DLLSpoolss.dll
Unicode and ANSI namesEnumPrintersW (Unicode) and EnumPrintersA (ANSI)
See Also
Printing and Print Spooler Overview
Printing and Print Spooler Functions
AddPrinter
DeletePrinter
GetPrinter
PRINTER_INFO_1
PRINTER_INFO_2
PRINTER_INFO_4
PRINTER_INFO_5
SetPrinter
Send comments about this topic to Microsoft
Build date: 7/11/2009
==原始网址==http://msdn.microsoft.com/en-us/library/dd162692(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:23:11