powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Windows [игнор отключен] [закрыт для гостей] / Событие на папку Windows XP?
5 сообщений из 5, страница 1 из 1
Событие на папку Windows XP?
    #34990060
Domninsky
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Гуру подскажите возможно ли в XP контролировать состояние папки. Мне надо чтобы когда в определенную папку падает файл любой на экран вываливалось какое-нибудь сообщение. Типа "файл готов". Это вообще возможно? Если да то как это делается?

Спасибо!
...
Рейтинг: 0 / 0
Событие на папку Windows XP?
    #34990099
vlad-p
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
MSDN: Obtaining Directory Change Notifications

Пример оттуда:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <tchar.h>

void RefreshDirectory(LPTSTR);
void RefreshTree(LPTSTR);

void WatchDirectory(LPTSTR lpDir)
{
   DWORD dwWaitStatus; 
   HANDLE dwChangeHandles[ 2 ]; 
   TCHAR lpDrive[ 4 ];
   TCHAR lpFile[_MAX_FNAME];
   TCHAR lpExt[_MAX_EXT];

   _tsplitpath(lpDir, lpDrive, NULL, lpFile, lpExt);

   lpDrive[ 2 ] = (TCHAR)'\\';
   lpDrive[ 3 ] = (TCHAR)'\0';
 
// Watch the directory for file creation and deletion. 
 
   dwChangeHandles[ 0 ] = FindFirstChangeNotification( 
      lpDir,                         // directory to watch 
      FALSE,                         // do not watch subtree 
      FILE_NOTIFY_CHANGE_FILE_NAME); // watch file name changes 
 
   if (dwChangeHandles[ 0 ] == INVALID_HANDLE_VALUE) 
      ExitProcess(GetLastError()); 
 
// Watch the subtree for directory creation and deletion. 
 
   dwChangeHandles[ 1 ] = FindFirstChangeNotification( 
      lpDrive,                       // directory to watch 
      TRUE,                          // watch the subtree 
      FILE_NOTIFY_CHANGE_DIR_NAME);  // watch dir. name changes 
 
   if (dwChangeHandles[ 1 ] == INVALID_HANDLE_VALUE) 
      ExitProcess(GetLastError()); 
 
// Change notification is set. Now wait on both notification 
// handles and refresh accordingly. 
 
   while (TRUE) 
   { 
   // Wait for notification.
 
      dwWaitStatus = WaitForMultipleObjects( 2 , dwChangeHandles, 
         FALSE, INFINITE); 
 
      switch (dwWaitStatus) 
      { 
         case WAIT_OBJECT_0: 
 
         // A file was created or deleted in the directory.
         // Refresh this directory and restart the notification.
 
            RefreshDirectory(lpDir); 
            if ( FindNextChangeNotification( 
                    dwChangeHandles[ 0 ]) == FALSE ) 
                ExitProcess(GetLastError()); 
            break; 
 
         case WAIT_OBJECT_0 +  1 : 
 
         // A directory was created or deleted in the subtree.
         // Refresh the tree and restart the notification.
 
            RefreshTree(lpDrive); 
            if (FindNextChangeNotification( 
                    dwChangeHandles[ 1 ]) == FALSE) 
                ExitProcess(GetLastError()); 
            break; 
 
        default: 
            ExitProcess(GetLastError()); 
      }
   }
}

void RefreshDirectory(LPTSTR lpDir)
{
   _tprintf(TEXT("Refresh the directory (%s).\n"), lpDir);
}

void RefreshTree(LPTSTR lpDrive)
{
   _tprintf(TEXT("Refresh the directory tree (%s).\n"), lpDrive);
}
...
Рейтинг: 0 / 0
Событие на папку Windows XP?
    #34990318
Domninsky
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
это на каком языке написано?
И в какой проект VS это пихать?
...
Рейтинг: 0 / 0
Событие на папку Windows XP?
    #34990373
Crazy_Driver
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Domninskyэто на каком языке написано?
И в какой проект VS это пихать?
Что-то мне подсказывает, что на C++, раз пример взят с MSDN
...
Рейтинг: 0 / 0
Событие на папку Windows XP?
    #34990609
Фотография Green2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Это С++
по #include <windows.h> видно

--

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
5 сообщений из 5, страница 1 из 1
Форумы / Windows [игнор отключен] [закрыт для гостей] / Событие на папку Windows XP?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]