Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Monitor directory to detect filesize changes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Monitor directory to detect filesize changes

    'Watch a directory to detect filesize change
    'Compiles in PB\CC and PB\DLL
    Code:
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    
    SUB DoEvents ()
      STATIC MSG AS tagMSG
      IF PeekMessage (MSG, %NULL, 0,0, %PM_REMOVE) THEN
      TranslateMessage MSG
      DispatchMessage MSG
     END IF
    END SUB
    
    FUNCTION PBMAIN() AS LONG
    ON ERROR RESUME NEXT
    LOCAL lDir AS DWORD
    LOCAL lFound1 AS DWORD
    LOCAL lFound2 AS DWORD
    DO
      lDir = FindFirstChangeNotification("c:\", 0, %FILE_NOTIFY_CHANGE_SIZE)
      DO
          lFound1 = WaitForSingleObject(lDir, 100)
          CALL DoEvents
      LOOP WHILE lFound1 <> 0
      DO
         #IF %DEF(%pb_dll32)
           MSGBOX "Change detected!" & TIME$
         #ELSE
           STDOUT "Change detected! " & TIME$
         #ENDIF
         lFound2 = FindNextChangeNotification(lDir)
         lFound2 = WaitForSingleObject(lDir, 100)
         EXIT DO
      LOOP
      lFound2 = FindCloseChangeNotification(lDir)
      CALL DoEvents
    LOOP
    END FUNCTION


    ------------------
    -
Working...
X