I don't know if this is a PB coding issue or not, so I put it o/t.
How do you detect files written to or read from by another exe? For instance, a program that creates temporary files...I'd like to view those temp files.
Thanks.
file write detection
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: file write detection
This is by no means a comprehensive solution to your goal. This posting is meant to serve only as a light nudge in the direction you need to go. Put the path of your choice in the code, run it and see the notification that arises when you create a new file in the path or change an existing file:
Again, just a nudge, I hope it helps you find your solution.
Code: Select all
Procedure WatchDisk(lcPathSpec.s)
lihNotify = FindFirstChangeNotification_(lcPathSpec, #True, #FILE_NOTIFY_CHANGE_LAST_WRITE)
If lihNotify <= #INVALID_HANDLE_VALUE
MessageRequester("Notice:","FindFirstChangeNotification failed. Error code: " + LTrim(Str(GetLastError_())))
ProcedureReturn
Else
MessageRequester("Notice:","FindFirstChangfeNotification instantiation succeeded. Handle is: " + LTrim(Str(lihNotify)))
EndIf
liWaitReturn = WaitForSingleObject_(lihNotify, #INFINITE)
If liWaitReturn >= #WAIT_FAILED
MessageRequester("Notice:","WaitForSingleObject failed. Error is: " + LTrim(Str(GetLastError_())))
ProcedureReturn
Else
MessageRequester("Notice:","Directory change in " + lcPathSpec + " occurred")
EndIf
liWaitReturn = FindCloseChangeNotification_(lihNotify)
ProcedureReturn liWaitReturn
EndProcedure
Debug WatchDisk("d:\")
BERESHEIT
Re: file write detection
netmaestro--that was a very good nudge; it does report when a change is made, but not what the change is. I hadn't looked at this issue since my post, but jpfiste posted a complete solution today:
http://purebasic.fr/english/viewtopic.php?f=12&t=47060
(and I added a followup question there, too...)
Thanks!
http://purebasic.fr/english/viewtopic.php?f=12&t=47060
(and I added a followup question there, too...)
Thanks!
