ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Forum AtoutFox : Re: je me mord la queud(tourner en rond) sur ce code   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

sam. 03 janvier 2015, 12h21
eddymaue
atoutfox.public.association

Re: je me mord la queud(tourner en rond) sur ce code

le fichier ylog.txt demeure vide

mon choix de dossier est c:\test

j'ai ajouté un fichier texte............. rien n'est notifié
j'ai modifier le nom de ce fichier ...... rien n'est notifié
j'ai ajouté un dossier .................. rien n'est notifié
j'ai détruit un dossier ................. rien n'est notifié
j'ai détruit un fichier ................. rien n'est notifié


alors ma question, est-ce que ce code fonctionne chez toi

histoire de savoir si j'ai un probleme avec mon environnement

merci de l'aide que tu m'apportes

Eddy a+


ybenam vient de nous annoncer :
*Source originale :http://www.news2news.com/vfp/Index.php?example=117

*adapté de cette source.

*execute le code, ouvre l'explorer, ajoute un fichier qqe aaa.txt, enregistre

le,ferme le,re ouvre le et modifie puis enregistre, * enfin supprime
le...Some tte crée des évènements.. *close le form
*tape clea all ...pour pouvoir accéder au ylog.txt

*ouvre ylog.txt et regarde les  évènements enregistrés.toutes les

notifications (dateTime() seulement)  sont passées par la (que tu peux voir *
dans la fenêtre arrière de command window (screen)
*Ici tu choisis le répertoire à surveiller ---(getdir())  l'original regarde

dans sys(2023) cad le temp folder. *NB: ce code ne donne que des
notifications (timedate())et ne renseigne pas sur la source exacte donnat
lieu à ces évènements *         regarde les sources que je t'ai indiquées,
elles ont plus explicites .
Public oForm,m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)
Set Alternate To m.yrep+"ylog.txt" &&(ajouté) :redirige toues les "?"
vers un seul fichier ylog.txt Set Alternate On
oForm = Createobject("Tform", Getdir()) && watching any dir for modifyed
events (create,delete,save....) oForm.Visible = .T.
* end of main

Define Class Tform As Form
#Define FILE_NOTIFY_CHANGE_FILE_NAME 1
#Define FILE_NOTIFY_CHANGE_DIR_NAME 2
#Define FILE_NOTIFY_CHANGE_ATTRIBUTES 4
#Define FILE_NOTIFY_CHANGE_SIZE 8
#Define FILE_NOTIFY_CHANGE_LAST_WRITE 16
#Define FILE_NOTIFY_CHANGE_LAST_ACCESS 32
#Define FILE_NOTIFY_CHANGE_CREATION 64
#Define FILE_NOTIFY_CHANGE_SECURITY 128
#Define INVALID_HANDLE_VALUE -1
#Define WAIT_OBJECT_0 0
#Define WATCHING_INTERVAL 1000 && milliseconds
Protected hNotify, PathBeingWatched
Width=400
Height=150
MaxButton=.F.
BorderStyle=2
ShowWindow=2 &&top level
AlwaysOnTop=.T. && au desuus
AutoCenter=.T.
Caption="Watching directory"
hNotify=INVALID_HANDLE_VALUE
PathBeingWatched=""
Add Object lblTarget As Label With Left=10, Top=7, AutoSize=.T.
Add Object tm As Timer With Interval=0
Add Object lblAlert As Label With Left=10, Top=30,;
Autosize=.T., Caption="Notification:"
Function Init(cPath)
This.Declare
This.PathBeingWatched = Fullpath(m.cPath)
If Not This.StartWatching()
= Messagebox("Notification handle error.")
Return .F.
Endif
Procedure Destroy
This.StopWatching
Protected Function StartWatching
Local lResult
* no subdirs watched

This.hNotify = FindFirstChangeNotification(;
THIS.PathBeingWatched, 0,;
FILE_NOTIFY_CHANGE_FILE_NAME +FILE_NOTIFY_CHANGE_SIZE +
FILE_NOTIFY_CHANGE_CREATION+;
FILE_NOTIFY_CHANGE_DIR_NAME+FILE_NOTIFY_CHANGE_LAST_WRITE ) && ICI les
évènements à surveiller au choix (ajoute les constantes pré définies de
windows)
lResult = (This.hNotify <> INVALID_HANDLE_VALUE)
If lResult
This.lblTarget.Caption = "Watched: " +;
THIS.PathBeingWatched
This.tm.Interval = WATCHING_INTERVAL
Endif
Return lResult
Protected Procedure ContinueWatching
If FindNextChangeNotification(This.hNotify) = 0
This.StopWatching
= Messagebox("Request error.")
Set Alternate Off && arrête l'enregistrement sur le ylog.txt
Clea All
This.Release
Endif
This.tm.Interval = WATCHING_INTERVAL
Protected Function StopWatching
This.tm.Interval = 0
If This.hNotify <> INVALID_HANDLE_VALUE
= FindCloseChangeNotification(This.hNotify)
Endif
Function _signaled && returns signaled state
Return (WaitForSingleObject(This.hNotify, 0) = WAIT_OBJECT_0)
Procedure _notify && triggered on event
Local cMessage
cMessage = "Notification: " + Program()+" "+Ttoc(Datetime())
This.lblAlert.Caption = cMessage
Activate Screen
? cMessage &&voir écran arrière du command window
This.ContinueWatching
Procedure tm.Timer
If Thisform._signaled()
Thisform._notify
Endif
Protected Procedure Declare
Declare SHORT FindNextChangeNotification In kernel32;
INTEGER hChangeHandle
Declare SHORT FindCloseChangeNotification In kernel32;
INTEGER hChangeHandle
Declare Integer FindFirstChangeNotification In kernel32;
STRING lpPathName, Integer bWatchSubtree,;
INTEGER dwNotifyFilter
Declare Integer WaitForSingleObject In kernel32;
INTEGER hHandle, Integer dwMilliseconds
Enddefine


--
Merci de partager avec moi votre immense savoir que je me ferai plaisir
d'absorber...
il va de soi que je vais vous en laisser un peu
Politesse et savoir vivre oblige ;0)
Permalink : http://www.atoutfox.org/nntp.asp?ID=0000015644
20 286 messages dans le forum • Liste complète des messages

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2026.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3