网站首页  词典首页

请输入您要查询的函数:

 

术语 findnextprinterchangenotification
释义 FindNextPrinterChangeNotification
语法:
BOOL FindNextPrinterChangeNotification(
__in HANDLE hChange,
__out_opt PDWORD pdwChange,
__in_opt LPVOID pPrinterNotifyOptions,
__out_opt LPVOID *ppPrinterNotifyInfo
);
FindNextPrinterChangeNotification功能
该FindNextPrinterChangeNotification函数检索有关的更改通知最近的更改通知信息对象与打印机或打印服务器。通话时,就改变通知对象等待操作此功能感到满意。
该功能还重置更改通知反对不终止状态。然后,您可以使用其他等待操作的对象继续监测打印机或打印服务器。该操作系统将设置对象的信号状态下时间一组指定的变化之一发生到打印机或打印服务器。该FindFirstPrinterChangeNotification函数创建更改通知对象,并指定成立的变化进行监测。
参数
hChange [in]
一个句柄,更改通知对象的打印机或打印服务器相关联。您获得这样的处理函数调用FindFirstPrinterChangeNotification。操作系统的设置此更改通知对象的信号状态时,它检测到的对象的更改通知过滤器所指定的变化之一。
pdwChange [指出,可选]
对变量的指针,其位被设置为显示所发生的变化引起的最新通知。该位可能被设置对应于该FindFirstPrinterChangeNotification电话fdwFilter参数指定的标志。该系统设置一个或更多下列位标志。
ValueMeaning
PRINTER_CHANGE_ADD_FORMA形式是添加到服务器。
PRINTER_CHANGE_ADD_JOBA打印作业被发送到打印机。
PRINTER_CHANGE_ADD_PORTA端口或监视器被添加到服务器。
PRINTER_CHANGE_ADD_PRINT_PROCESSORA打印处理器被添加到服务器。
PRINTER_CHANGE_ADD_PRINTERA打印机添加到服务器。
PRINTER_CHANGE_ADD_PRINTER_DRIVERA打印机驱动程序添加到服务器。
PRINTER_CHANGE_CONFIGURE_PORTA端口被配置在服务器上。
PRINTER_CHANGE_DELETE_FORMA形式是从服务器中删除。
PRINTER_CHANGE_DELETE_JOBA工作已删除。
PRINTER_CHANGE_DELETE_PORTA端口或监测是从服务器中删除。
PRINTER_CHANGE_DELETE_PRINT_PROCESSORA打印处理器是从服务器中删除。
PRINTER_CHANGE_DELETE_PRINTERA打印机已删除。
PRINTER_CHANGE_DELETE_PRINTER_DRIVERA打印机驱动程序从服务器中删除。
PRINTER_CHANGE_FAILED_CONNECTION_PRINTERA打印机连接失败。
PRINTER_CHANGE_SET_FORMA形式设置在服务器上。
PRINTER_CHANGE_SET_JOBA工作成立。
PRINTER_CHANGE_SET_PRINTERA打印机成立。
PRINTER_CHANGE_SET_PRINTER_DRIVERA打印机驱动程序设置。
PRINTER_CHANGE_WRITE_JOBJob数据写。
PRINTER_CHANGE_TIMEOUTThe工作超时。
PRINTER_CHANGE_SERVERWindows 7:变化发生在服务器上。
pPrinterNotifyOptions [中,可选]
一个 PRINTER_NOTIFY_OPTIONS结构的指针。设置这个结构旗成员PRINTER_NOTIFY_OPTIONS_REFRESH,导致函数返回打印机的所有监测信息等领域的当前数据。该函数忽略了结构的所有其他成员。此参数可以为NULL。
ppPrinterNotifyInfo [指出,可选]
一个指针变量,它接收系统指针的指针分配,只读缓冲区。函数调用FreePrinterNotifyInfo免费当您与它完成了缓冲区。此参数可以为NULL如果没有信息是必需的。
缓冲区包含PRINTER_NOTIFY_INFO结构,它包含了PRINTER_NOTIFY_INFO_DATA结构的数组。数组的每个元素包含有关在FindFirstPrinterChangeNotification电话pPrinterNotifyOptions参数指定的领域之一的信息。通常情况下,该函数只规定的改变引起的最新通知领域的数据。但是,如果结构指向的pPrinterNotifyOptions参数指定PRINTER_NOTIFY_OPTIONS_REFRESH,功能为所有监测领域的数据。
如果PRINTER_NOTIFY_INFO_DISCARDED位在PRINTER_NOTIFY_INFO结构,溢出或错误旗成员设置发生,通知可能已丢失。在这种情况下,没有额外的通知将发送到您的第二FindNextPrinterChangeNotification调用指定PRINTER_NOTIFY_OPTIONS_REFRESH。
返回值
如果函数成功,返回值是一个非零值。
如果函数失败,返回值是零。
备注
呼叫后,就通知等待操作的FindNextPrinterChangeNotification函数对象创建FindFirstPrinterChangeNotification得到满足。调用FindNextPrinterChangeNotification让您掌握在满足等待操作变化信息,并重置通知对象,因此可以预示未来的时候发生变化。
有一个例外,不要调用FindNextPrinterChangeNotification功能的改变,是否通知对象不在信号状态。如果一个等待函数返回值WAIT_TIMEOUT,更改对象不在信号状态。函数调用FindNextPrinterChangeNotification只有等待函数成功不超时。唯一的例外是当FindNextPrinterChangeNotification但与pPrinterNotifyOptions参数设置PRINTER_NOTIFY_OPTIONS_REFRESH位调用。注意,即使在设置了此标志的PRINTER_NOTIFY_INFO_DISCARDED为标志,还是有可能将在ppPrinterNotifyInfo参数设置。
继续监测变化的打印机或打印服务器,重复呼叫等待功能的一个周期,然后调用FindNextPrinterChangeNotification功能研究的变化和重置通知对象。
FindNextPrinterChangeNotification可以合并成一个通知同一台打印机的信息领域的多方面的变化。如果发生这种情况,该函数通常折叠成一个在ppPrinterNotifyInfo PRINTER_NOTIFY_INFO_DATA结构排列的单入职领域的所有变化,单一入口只报告最新的信息。然而,对一些工作和打印机信息领域,函数可以返回同一领域的多个数组项。在这种情况下,该字段的最后数组项报告当前的数据,和早期作品包含的中间阶段的数据。
当您不再需要更改通知对象,通过调用关闭FindClosePrinterChangeNotification函数。
注意:在带有Service Pack 2(SP2)和更高版本XP中,Internet连接防火墙(ICF)块默认打印机端口,而是对文件和打印共享例外可以启用。如果用户对一台打印机连接到另一台机器,并且未启用的例外,那么用户将不会收到来自服务器的打印机更改通知。一台机器管理员必须启用例外。
实例
下面的代码示例演示如何可以监测使用这些功能打印机的状态。
// get change notification handle for the printer
chgObject = FindFirstPrinterChangeNotification( hPrinter, PRINTER_CHANGE_JOB, 0, NULL);
if (chgObject != INVALID_HANDLE_VALUE) {
while (bKeepMonitoring) {
// wait for the change notification
WaitForSingleObject(chgObject, INFINITE);
//
fcnreturn = FindNextPrinterChangeNotification(chgObject, pdwChange, NULL, NULL);
if (fcnreturn) {
// check value of *pdwChange and deal with the indicated change
}
// insert some mechanism to stop monitoring
// if (something happens) bKeepMontoring = false;
}
// close Printer Change Notification handle when finished.
FindClosePrinterChangeNotification(chgObject);
} else {
// unable to open printer change notification handle
dwStatus = GetLastError();
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinspool.h(头文件:winuser.h)
LibraryWinspool.lib
参见
Printing and Print Spooler Overview
Printing and Print Spooler 函数
FindClosePrinterChangeNotification
FindFirstPrinterChangeNotification
PRINTER_NOTIFY_INFO
PRINTER_NOTIFY_INFO_DATA
PRINTER_NOTIFY_OPTIONS
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月11日
==英文原文==FindNextPrinterChangeNotification Function
The FindNextPrinterChangeNotification function retrieves information about the most recent change notification for a change notification object associated with a printer or print server. Call this function when a wait operation on the change notification object is satisfied.
The function also resets the change notification object to the not-signaled state. You can then use the object in another wait operation to continue monitoring the printer or print server. The operating system will set the object to the signaled state the next time one of a specified set of changes occurs to the printer or print server. The FindFirstPrinterChangeNotification function creates the change notification object and specifies the set of changes to be monitored.
Syntax
BOOL FindNextPrinterChangeNotification(
__in HANDLE hChange,
__out_opt PDWORD pdwChange,
__in_opt LPVOID pPrinterNotifyOptions,
__out_opt LPVOID *ppPrinterNotifyInfo
);
Parameters
hChange [in]
A handle to a change notification object associated with a printer or print server. You obtain such a handle by calling the FindFirstPrinterChangeNotification function. The operating system sets this change notification object to the signaled state when it detects one of the changes specified in the object's change notification filter.
pdwChange [out, optional]
A pointer to a variable whose bits are set to indicate the changes that occurred to cause the most recent notification. The bit flags that might be set correspond to those specified in the fdwFilter parameter of the FindFirstPrinterChangeNotification call. The system sets one or more of the following bit flags.
ValueMeaning
PRINTER_CHANGE_ADD_FORMA form was added to the server.
PRINTER_CHANGE_ADD_JOBA print job was sent to the printer.
PRINTER_CHANGE_ADD_PORTA port or monitor was added to the server.
PRINTER_CHANGE_ADD_PRINT_PROCESSORA print processor was added to the server.
PRINTER_CHANGE_ADD_PRINTERA printer was added to the server.
PRINTER_CHANGE_ADD_PRINTER_DRIVERA printer driver was added to the server.
PRINTER_CHANGE_CONFIGURE_PORTA port was configured on the server.
PRINTER_CHANGE_DELETE_FORMA form was deleted from the server.
PRINTER_CHANGE_DELETE_JOBA job was deleted.
PRINTER_CHANGE_DELETE_PORTA port or monitor was deleted from the server.
PRINTER_CHANGE_DELETE_PRINT_PROCESSORA print processor was deleted from the server.
PRINTER_CHANGE_DELETE_PRINTERA printer was deleted.
PRINTER_CHANGE_DELETE_PRINTER_DRIVERA printer driver was deleted from the server.
PRINTER_CHANGE_FAILED_CONNECTION_PRINTERA printer connection has failed.
PRINTER_CHANGE_SET_FORMA form was set on the server.
PRINTER_CHANGE_SET_JOBA job was set.
PRINTER_CHANGE_SET_PRINTERA printer was set.
PRINTER_CHANGE_SET_PRINTER_DRIVERA printer driver was set.
PRINTER_CHANGE_WRITE_JOBJob data was written.
PRINTER_CHANGE_TIMEOUTThe job timed out.
PRINTER_CHANGE_SERVERWindows 7: A change occured on the server.

pPrinterNotifyOptions [in, optional]
A pointer to a PRINTER_NOTIFY_OPTIONS structure. Set the Flags member of this structure to PRINTER_NOTIFY_OPTIONS_REFRESH, to cause the function to return the current data for all monitored printer information fields. The function ignores all other members of the structure. This parameter can be NULL.
ppPrinterNotifyInfo [out, optional]
A pointer to a pointer variable that receives a pointer to a system-allocated, read-only buffer. Call the FreePrinterNotifyInfo function to free the buffer when you are finished with it. This parameter can be NULL if no information is required.
The buffer contains a PRINTER_NOTIFY_INFO structure, which contains an array of PRINTER_NOTIFY_INFO_DATA structures. Each element of the array contains information about one of the fields specified in the pPrinterNotifyOptions parameter of the FindFirstPrinterChangeNotification call. Typically, the function provides data only for the fields that changed to cause the most recent notification. However, if the structure pointed to by the pPrinterNotifyOptions parameter specifies PRINTER_NOTIFY_OPTIONS_REFRESH, the function provides data for all monitored fields.
If the PRINTER_NOTIFY_INFO_DISCARDED bit is set in the Flags member of the PRINTER_NOTIFY_INFO structure, an overflow or error occurred, and notifications may have been lost. In this case, no additional notifications will be sent until you make a second FindNextPrinterChangeNotification call that specifies PRINTER_NOTIFY_OPTIONS_REFRESH.
Return Value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero.
Remarks
Call the FindNextPrinterChangeNotification function after a wait operation on a notification object created by FindFirstPrinterChangeNotification has been satisfied. Calling FindNextPrinterChangeNotification lets you obtain information about the change that satisfied the wait operation, and resets the notification object so it can be signaled when the next change occurs.
With one exception, do not call the FindNextPrinterChangeNotification function if the change notification object is not in the signaled state. If a wait function returns the value WAIT_TIMEOUT, the change object is not in the signaled state. Call the FindNextPrinterChangeNotification function only if the wait function succeeds without timing out. The exception is when FindNextPrinterChangeNotification is called with the PRINTER_NOTIFY_OPTIONS_REFRESH bit set in the pPrinterNotifyOptions parameter. Note that even when this flag is set, it is still possible for the the PRINTER_NOTIFY_INFO_DISCARDED flag to be set in the ppPrinterNotifyInfo parameter.
To continue monitoring the printer or print server for changes, repeat the cycle of calling one of the wait functions , and then calling the FindNextPrinterChangeNotification function to examine the change and reset the notification object.
FindNextPrinterChangeNotification may combine multiple changes to the same printer information field into a single notification. When this occurs, the function typically collapses all changes for the field into a single entry in the array of PRINTER_NOTIFY_INFO_DATA structures in ppPrinterNotifyInfo; the single entry reports only the most current information. However, for some job and printer information fields, the function can return multiple array entries for the same field. In this case, the last array entry for the field reports the current data, and the earlier entries contain the data for the intermediate stages.
When you no longer need the change notification object, close it by calling the FindClosePrinterChangeNotification function.
Note In Windows XP with Service Pack 2 (SP2) and later, the Internet Connection Firewall (ICF) blocks printer ports by default, but an exception for File and Print Sharing can be enabled. If a user makes a printer connection to another machine, and the exception is not enabled, then the user will not receive printer change notifications from the server. A machine admin will have to enable exception.
Examples
The following code sample illustrates how you might monitor printer status by using these functions.

// get change notification handle for the printer
chgObject = FindFirstPrinterChangeNotification( hPrinter, PRINTER_CHANGE_JOB, 0, NULL);
if (chgObject != INVALID_HANDLE_VALUE) {
while (bKeepMonitoring) {
// wait for the change notification
WaitForSingleObject(chgObject, INFINITE);
//
fcnreturn = FindNextPrinterChangeNotification(chgObject, pdwChange, NULL, NULL);
if (fcnreturn) {
// check value of *pdwChange and deal with the indicated change
}
// insert some mechanism to stop monitoring
// if (something happens) bKeepMontoring = false;
}
// close Printer Change Notification handle when finished.
FindClosePrinterChangeNotification(chgObject);
} else {
// unable to open printer change notification handle
dwStatus = GetLastError();
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinspool.h (include Windows.h)
LibraryWinspool.lib
See Also
Printing and Print Spooler Overview
Printing and Print Spooler Functions
FindClosePrinterChangeNotification
FindFirstPrinterChangeNotification
PRINTER_NOTIFY_INFO
PRINTER_NOTIFY_INFO_DATA
PRINTER_NOTIFY_OPTIONS
Send comments about this topic to Microsoft
Build date: 7/11/2009
==原始网址==http://msdn.microsoft.com/en-us/library/dd162723(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:25:50