Форум программистов «Весельчак У»
  *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

  • Рекомендуем проверить настройки временной зоны в вашем профиле (страница "Внешний вид форума", пункт "Часовой пояс:").
  • У нас больше нет рассылок. Если вам приходят письма от наших бывших рассылок mail.ru и subscribe.ru, то знайте, что это не мы рассылаем.
   Начало  
Наши сайты
Помощь Поиск Календарь Почта Войти Регистрация  
 
Страниц: [1]   Вниз
  Печать  
Автор Тема: Перехват printer jobs  (Прочитано 9753 раз)
0 Пользователей и 1 Гость смотрят эту тему.
Тайлер
Гость
« : 02-12-2003 17:39 » 

В Windows XP необходимо подсчитать количество распечатанных страниц.
Я так полагаю что надо перехватывать Printer Job. В MSDN откопал функцию FindFirstPrinterChangeNotification и соответственно FindNextPrinterChangeNotification. В правильном направлении я двигаюсь? И если не сложно примерчик приблизительный или алгоритм...
Записан
Гром
Птычк. Тьфу, птычник... Вот!
Готовлюсь к пенсии

il
Offline Offline
Пол: Мужской
Бодрый птах


« Ответ #1 : 02-12-2003 18:01 » 

Тайлер, честно говоря не знаю
Брось ка чюда описание тех функций из MSDN
Записан

А птичку нашу прошу не обижать!!!
Тайлер
Гость
« Ответ #2 : 03-12-2003 10:15 » 

FindFirstPrinterChangeNotification

The FindFirstPrinterChangeNotification function creates a change notification object and returns a handle to the object. You can then use this handle in a call to one of the wait functions to monitor changes to the printer or print server.
The FindFirstPrinterChangeNotification call specifies the type of changes to be monitored. You can specify a set of conditions to monitor for changes, a set of printer information fields to monitor, or both.
A wait operation on the change notification handle succeeds when one of the specified changes occurs in the specified printer or print server. You then call the FindNextPrinterChangeNotification function to retrieve information about the change, and to reset the change notification object for use in the next wait operation.

HANDLE FindFirstPrinterChangeNotification(
    HANDLE hPrinter, // handle to printer
    DWORD fdwFlags, // conditions to monitor
    DWORD fdwOptions, // reserved, must be zero
    LPVOID pPrinterNotifyOptions // fields to monitor
);

Parameters
hPrinter
[in] Handle to the printer or print server that you want to monitor. Use the openPrinter or AddPrinter function to retrieve a printer handle.
fdwFlags
[in] Specify the conditions that will cause the change notification object to enter a signaled state. A change notification occurs when one or more of the specified conditions are met. The fdwFlags parameter can be zero if pPrinterNotifyOptions is non-NULL. This parameter can be one or more of the following values.
Value                              Meaning
PRINTER_CHANGE_FORM  Notify of any changes to a form. You can set this
                                      general flag or one or more of the following specific flags:
                                      PRINTER_CHANGE_ADD_FORM
                                      PRINTER_CHANGE_SET_FORM
                                      PRINTER_CHANGE_DELETE_FORM
PRINTER_CHANGE_JOB    Notify of any changes to a job. You can set this general
                                      flag or one or more of the following specific flags:
                                      PRINTER_CHANGE_ADD_JOB
                                      PRINTER_CHANGE_SET_JOB
                                      PRINTER_CHANGE_DELETE_JOB
                                      PRINTER_CHANGE_WRITE_JOB
PRINTER_CHANGE_PORT  Notify of any changes to a port. You can set this general
                                      flag or one or more of the following specific flags:
                                      PRINTER_CHANGE_ADD_PORT
                                      PRINTER_CHANGE_CONFIGURE_PORT
                                      PRINTER_CHANGE_DELETE_PORT
PRINTER_CHANGE_PRINT_PROCESSOR Notify of any changes to a print processor.
                                     You can set this general flag or one or more of the
                                     following specific flags:
                                     PRINTER_CHANGE_ADD_PRINT_PROCESSOR
                                     PRINTER_CHANGE_DELETE_PRINT_PROCESSOR
PRINTER_CHANGE_PRINTER Notify of any changes to a printer. You can set this
                                     general flag or one or more of the following specific flags:
                                     PRINTER_CHANGE_ADD_PRINTER
                                     PRINTER_CHANGE_SET_PRINTER
                                     PRINTER_CHANGE_DELETE_PRINTER
                                     PRINTER_CHANGE_FAILED_CONNECTION_PRINTER
PRINTER_CHANGE_PRINTER_DRIVER Notify of any changes to a printer driver.
                                     You can set this general flag or one or more of the following
                                     specific flags:
                                     PRINTER_CHANGE_ADD_PRINTER_DRIVER
                                     PRINTER_CHANGE_SET_PRINTER_DRIVER
                                     PRINTER_CHANGE_DELETE_PRINTER_DRIVER
PRINTER_CHANGE_ALL Notify if any of the preceding changes occur.

For descriptions of the more specific flags in the preceding table, see the
FindNextPrinterChangeNotification function.
fdwOptions
Reserved; must be zero.
pPrinterNotifyOptions
[in] Pointer to a PRINTER_NOTIFY_OPTIONS structure. The pTypes member of this structure is an array of one or more PRINTER_NOTIFY_OPTIONS_TYPE structures, each of which specifies a printer information field to monitor. A change notification occurs when one or more of the specified fields changes. When a change occurs, the FindNextPrinterChangeNotification function can retrieve the new printer information. This parameter can be NULL if fdwFlags is nonzero.
For a list of fields that can be monitored, see PRINTER_NOTIFY_OPTIONS_TYPE.
Return Values
If the function succeeds, the return value is a handle to a change notification object associated with the specified printer or print server.
If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
Remarks
To monitor a printer or print server, call the FindFirstPrinterChangeNotification function, then use the returned change notification object handle in a call to one of the wait functions. A wait operation on a change notification object is satisfied when the change notification object enters the signaled state. The system signals the object when one or more of the changes specified by fdwFlags or pPrinterNotifyOptions
occurs in the monitored printer or print server.
When you call FindFirstPrinterChangeNotification, either fdwFlags must be nonzero or
pPrinterNotifyOptions must be non-NULL. If both are specified, notifications will occur for both.
When a wait operation on a printer change notification object is satisfied, call the FindNextPrinterChangeNotification function to determine the cause of the notification. For a condition specified by fdwFlags, FindNextPrinterChangeNotification reports the condition or conditions that changed. For a printer information field specified by pPrinterNotifyOptions , FindNextPrinterChangeNotification reports the field or fields that changed as well as the new information for these fields. FindNextPrinterChangeNotification also resets the change notification object to the nonsignaled state so you can use it in another wait operation to continue monitoring the printer or print server.
Do not call the FindNextPrinterChangeNotification function if the change notification object is not in the signaled state. If the 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.
When you no longer need the change notification object, close it by calling the FindClosePrinterChangeNotification function.
Записан
Тайлер
Гость
« Ответ #3 : 03-12-2003 10:17 » new

Да, не очень понятно получилось
Записан
Страниц: [1]   Вверх
  Печать  
 

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines