Guidance
指路人
g.yi.org
software / rapidq / Examples / File & Directory / Watch_SubTree.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'from: John White  Sep 6th, 2002, 11:21am
     $INCLUDE "RAPIDQ.INC"
     $OPTIMIZE ON
     $APPTYPE GUI
     $TYPECHECK ON
     $ESCAPECHARS ON

     CONST WATCH_DIR_ONLY=0
     CONST WATCH_SUBDIRS=1
     CONST WAIT_FOR_ONE=0
     CONST WAIT_FOR_ALL=1
     CONST INVALID_HANDLE_VALUE=-1
     CONST WAIT_OBJECT_0=0
     CONST WAIT_ABANDONED=128
     CONST WAIT_TIMEOUT=258
     CONST WAIT_FAILED=&HFFFFFFFF
     CONST FNC_FILENAME=1
     CONST FNC_DIRNAME=2
     CONST FNC_ATTRS=4
     CONST FNC_SIZE=8
     CONST FNC_LASTWRITE=16
     CONST FNC_SECURITY=256
     CONST FNC_ALL=FNC_FILENAME OR FNC_DIRNAME OR FNC_ATTRS OR FNC_SIZE OR FNC_LASTWRITE
     CONST INFINITE_TIMEOUT=&HFFFF

     DECLARE FUNCTION FindCloseChangeNotification LIB "kernel32.dll" ALIAS "FindCloseChangeNotification" (hChange AS LONG) AS LONG
     DECLARE FUNCTION FindFirstChangeNotification LIB "kernel32.dll" ALIAS "FindFirstChangeNotificationA" (pathName AS LONG, subTree AS LONG, filter AS LONG) AS LONG
     DECLARE FUNCTION FindNextChangeNotification LIB "kernel32.dll" ALIAS "FindNextChangeNotification" (hChange AS LONG) AS LONG
     DECLARE FUNCTION GetLastError LIB "kernel32.dll" ALIAS "GetLastError" () AS LONG
     DECLARE FUNCTION WaitForSingleObject LIB "kernel32.dll" ALIAS "WaitForSingleObject" (hHandle AS LONG, timeout AS LONG) AS LONG
     DECLARE FUNCTION WaitForMultipleObjects LIB "kernel32.dll" ALIAS "WaitForMultipleObjects" (numObjs AS LONG, hObjects AS LONG, waitAll AS LONG, timeout AS LONG) AS LONG

     DIM objects(0 TO 9) AS LONG, rtnobj AS LONG, rtn AS LONG, z AS LONG
     DIM path_Name$ AS STRING

     path_Name$="C:\\My Documents"

     SUB Watch_SubTree
      objects(0)=FindFirstChangeNotification(VARPTR(path_Name$), WATCH_SUBDIRS, FNC_FILENAME)
      IF objects(0)<>INVALID_HANDLE_VALUE THEN
       objects(1)=FindFirstChangeNotification(VARPTR(path_Name$), WATCH_SUBDIRS, FNC_DIRNAME)
       IF objects(1)<>INVALID_HANDLE_VALUE THEN
        objects(2)=FindFirstChangeNotification(VARPTR(path_Name$), WATCH_SUBDIRS, FNC_ATTRS)
        IF objects(2)<>INVALID_HANDLE_VALUE THEN
         objects(3)=FindFirstChangeNotification(VARPTR(path_Name$), WATCH_SUBDIRS, FNC_SIZE)
         IF objects(3)<>INVALID_HANDLE_VALUE THEN
          objects(4)=FindFirstChangeNotification(VARPTR(path_Name$), WATCH_SUBDIRS, FNC_LASTWRITE)
          IF objects(4)<>INVALID_HANDLE_VALUE THEN
           rtnobj=WaitForMultipleObjects(5, @objects(0), WAIT_FOR_ONE, INFINITE_TIMEOUT)
           IF rtnobj<>WAIT_FAILED THEN
            SHOWMESSAGE("object: "+STR$(rtnobj))
            rtn=FindNextChangeNotification(objects(rtnobj))
            IF rtn<>0 THEN
             SHOWMESSAGE("TRUE")
            ELSE
             SHOWMESSAGE("FAILED")
            END IF
           END IF
           FOR z=0 TO 4
            rtn=FindCloseChangeNotification(objects(z))
            IF rtn<>0 THEN
'ShowMessage("Closed")
            ELSE
'ShowMessage("not closed")
            END IF
           NEXT
          END IF
         END IF
        END IF
       END IF
      END IF
     END SUB

     Watch_SubTree
掌柜推荐
 
 
¥477.00 ·
 
 
¥918.00 ·
 
 
¥370.00 ·
 
 
¥271.00 ·
 
 
¥995.00 ·
 
 
¥1,580.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-09-16 07:41:24