Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Некоторые системные функции Windows.doc
Скачиваний:
32
Добавлен:
28.06.2014
Размер:
98.3 Кб
Скачать

Некоторые системные функции Windows

  1. Организация слежения за доступом к папке (принтеру, разделу реестра):

The FindFirstChangeNotification function creates a change notification handle and sets up initial change notification filter conditions. A wait on a notification handle succeeds when a change matching the filter conditions occurs in the specified directory or subtree.

HANDLE FindFirstChangeNotification(

LPCTSTR lpPathName, // pointer to name of directory to watch

BOOL bWatchSubtree, // flag for monitoring directory or directory tree

DWORD dwNotifyFilter // filter conditions to watch for );

The FindNextChangeNotification function requests that the operating system signal a change notification handle the next time it detects an appropriate change.

BOOL FindNextChangeNotification(

HANDLE hChangeHandle // handle to change notification to signal );

The FindCloseChangeNotification function stops change notification handle monitoring.

BOOL FindCloseChangeNotification(

HANDLE hChangeHandle // handle to change notification to close );

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.

HANDLE FindFirstPrinterChangeNotification(

HANDLE hPrinter, // handle to printer or print server to monitor for changes

DWORD fdwFlags, // flags that specify the conditions to monitor

DWORD fdwOptions, // reserved, must be zero

LPVOID pPrinterNotifyOptions // pointer to structure specifying printer information to monitor );

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.

BOOL FindNextPrinterChangeNotification(

HANDLE hChange, // handle to change notification object of interest

PDWORD pdwChange, // pointer to a value that indicates the condition that changed

LPVOID pPrinterNotifyOptions, // pointer to a structure that specifies a refresh flag

LPVOID *ppPrinterNotifyInfo // pointer to a pointer that receives printer information buffer );

The FindClosePrinterChangeNotification function closes a change notification object created by calling the FindFirstPrinterChangeNotification function. The printer or print server associated with the change notification object will no longer be monitored by that object.

BOOL FindClosePrinterChangeNotification(

HANDLE hChange // handle to change notification object to close

);

The RegNotifyChangeKeyValue function notifies the caller about changes to the attributes or contents of a specified registry key. Note that the function does not notify the caller if the specified key is deleted.

LONG RegNotifyChangeKeyValue(

HKEY hKey, // handle of key to watch

BOOL bWatchSubtree, // flag for subkey notification

DWORD dwNotifyFilter, // changes to be reported

HANDLE hEvent, // handle of signaled event

BOOL fAsynchronous // flag for asynchronous reporting );

The WaitForSingleObject function returns when one of the following occurs:

· The specified object is in the signaled state.

· The time-out interval elapses.

The WaitForSingleObject function can wait for the following objects:

Object Description

Change notification The FindFirstChangeNotification function returns the handle. A change notification object's state is signaled when a specified type of change occurs within a specified directory or directory tree.

DWORD WaitForSingleObject(

HANDLE hHandle, // handle of object to wait for

DWORD dwMilliseconds // time-out interval in milliseconds );

The WaitForMultipleObjects function returns when one of the following occurs:

· Either any one or all of the specified objects are in the signaled state.

· The time-out interval elapses.

The WaitForMultipleObjects function can specify handles of any of the following object types in the lpHandles array:

Object Description

Change notification The FindFirstChangeNotification function returns the handle. A change notification object's state is signaled when a specified type of change occurs within a specified directory or directory tree.

DWORD WaitForMultipleObjects(

DWORD nCount, // number of handles in the object handle array

CONST HANDLE *lpHandles, // pointer to the object-handle array

BOOL bWaitAll, // wait flag

DWORD dwMilliseconds // time-out interval in milliseconds );