AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Languages, Compilers and Interpreters C,C++,C#,.NET,Java,PHP,Perl,SQL and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Jan 16, 2004, 08:01   #1
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,178
Rep Power: 7
Reputation: 45
мониторинг файловый операций

никак не могу найти соответствующие функции в мсдн, никто не подскажет, как подписываться на файловые операции?
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 08:47   #2
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,546
Rep Power: 11
Reputation: 169
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Пахать начинаем от ReadDirectoryChanges по ликам.
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 10:10   #3
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,178
Rep Power: 7
Reputation: 45
Quote:
Originally Posted by Agregat
Пахать начинаем от ReadDirectoryChanges по ликам.
спасибо!

но такая проблема: имеется только юникод-версия функции, с W на конце. без W или с A отсутствует. а чем пользоваться для не-nt версий виндов?
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 10:26   #4
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,178
Rep Power: 7
Reputation: 45
кстати, эта функция не осуществляет установку хука. а есть ли такая возможность вообще? или это делается на уровне драйвера?
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 11:10   #5
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,546
Rep Power: 11
Reputation: 169
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Можно и с хуком, но с этим методом я не знаком. Под окна не НТ скорее всего надо вешать хук. Всякие Вижуал Ц делают скорее всего через эту функцию : FindFirstChangeNotification.
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 12:03   #6
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,546
Rep Power: 11
Reputation: 169
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Вот код, который я накидал минут за 10
PHP Code:
// FileNotifications.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <string>
using namespace std;
DWORD WINAPI MonitoringThread(void pParam);
static 
bool g_bGoOn true;
int main(int argccharargv[])
{
 
cout << "Enter dir to monitor : ";
 
string sDir;
 
cin >> sDir;
 
DWORD dwID;
 ::
CreateThread(NULL0MonitoringThread, (void *)sDir.c_str(), 0, &dwID);
 
char ch;
 while (
ch getch())
 {
  if (
'q' == ch || 'Q' == ch)
   break;
 }
 
g_bGoOn false;
 
Sleep(300);
 return 
0;
}

DWORD WINAPI MonitoringThread(void pParam)
{
 const 
char pszDir = (char *) pParam;
 
HANDLE hMonitor = ::FindFirstChangeNotification(pszDirfalseFILE_NOTIFY_CHANGE_LAST_WRITE);
 
//everything worked wrong
 
if (INVALID_HANDLE_VALUE == hMonitor)
  
ExitProcess(-1);
 
///
 
cout << "Started monitoring " << pszDir << " directory." << endl;
 
DWORD dw;
 while (
g_bGoOn)
 {
  
dw = ::WaitForSingleObject(hMonitor1000);
  switch (
dw)
  {
  case 
WAIT_TIMEOUT:
   
//time out and nothing has changed
   
break;
  case 
WAIT_OBJECT_0:
   
//we have changes in the monitored directory
   
::FindNextChangeNotification(hMonitor);
   
cout << "In the monitored directory change(s) have occured!" << endl;
   break;
  default:
   
//means there's some other error
   
cout << "Error has occured. Monitoring has stopped. Press 'q' to quit" << 
endl;
   
g_bGoOn false;
   break;
  }
 }
 
//close the search
 
::FindCloseChangeNotification(hMonitor);
 return 
0;

__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 12:19   #7
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,178
Rep Power: 7
Reputation: 45
а как затребовать уведомление на любой доступ (например, открытие на чтение без изменения) к файлу, а не только факт записи?
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 12:22   #8
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,546
Rep Power: 11
Reputation: 169
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Зайди на sysinternals.com и посмотри, что там написано про FileMon
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 12:56   #9
Administrator
 
acid's Avatar
 
Join Date: Sep 2001
Location: Yerevan, Armenia
Posts: 7,161
Blog Entries: 15
Rep Power: 10
Reputation: 298
Quote:
Originally Posted by Agregat
Зайди на sysinternals.com и посмотри, что там написано про FileMon
там когда-то были исходники этого FileMon-a, может у кого сохранились?
__________________
Chat with acid


acid is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 13:46   #10
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,178
Rep Power: 7
Reputation: 45
Quote:
Originally Posted by Agregat
Зайди на sysinternals.com и посмотри, что там написано про FileMon
там как раз то, чего я опасался - через установку своего драйвера
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old Jan 16, 2004, 14:30   #11
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,546
Rep Power: 11
Reputation: 169
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Новый файлмон вроде без драйвера... или он как-то по другому это делает...
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Oct 1, 2004, 07:44   #12
Младенец
 
Join Date: Oct 2004
Location: rus
Posts: 4
Rep Power: 0
Reputation: 10
Вот такой вопрос :
пробывал прокомпилировать но выдало ошибку
Code:
[C++ Fehler] prov.cpp(1): E2209 include-Datei 'STDAFX.H' kann nicht geoffnet werden.
[C++ Warnung] prov.cpp(16): W8060 Moglicherweise inkorrekte Zuweisung
'STDAFX.H' - где взять ?
-Time- is offline   Reply With Quote Quote selected
Old Oct 1, 2004, 10:14   #13
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,546
Rep Power: 11
Reputation: 169
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Пилят. Ц++ по немецки. stdafx.h - убери в VC use precompiled headers или создай пустий stdafx.h и stdafx.cpp и инклюдни первый из второго, и первый инклюдни во все цпп файлы.
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Oct 1, 2004, 11:18   #14
Младенец
 
Join Date: Oct 2004
Location: rus
Posts: 4
Rep Power: 0
Reputation: 10
спасибо
-Time- is offline   Reply With Quote Quote selected
Old Oct 1, 2004, 11:22   #15
Младенец
 
Join Date: Oct 2004
Location: rus
Posts: 4
Rep Power: 0
Reputation: 10
Quote:
Пилят. Ц++ по немецки.
какую версию имеем такое и рады
-Time- is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:09.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link