Results 1 to 5 of 5

Thread: Urgent

  1. #1

    Thread Starter
    Hyperactive Member kourosh's Avatar
    Join Date
    Aug 1999
    Location
    Vancouver, British Columbia, Canada
    Posts
    256

    Unhappy

    Hi, I am writing a watch program. The program should look over a folder and if somebody add/delete or rename any file, the program give them a message and log the error. I have been successful with the add/delete but I havn't had any luck detecting if anybody has rename the files. I am using a file control.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Loop regulary trough the items, and compare them to static copy of it in a method.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Hyperactive Member kourosh's Avatar
    Join Date
    Aug 1999
    Location
    Vancouver, British Columbia, Canada
    Posts
    256

    Exclamation Doesn't work!

    Thanks for the help but how would I make an static copy of the item when they are dynamic and changable by the user?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well you could redim it...
    Static strcopy$()

    Redim preserve strcopy(list.listcount)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You can use the FindFirstChangeNotification() API to have you program wait for a Change to be made before going out to check and see what file it was, i.e.
    Code:
    Private Declare Function FindFirstChangeNotification Lib "kernel32" Alias "FindFirstChangeNotificationA" (ByVal lpPathName As String, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long) As Long
    Private Declare Function FindNextChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
    Private Declare Function FindCloseChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
    Private Declare Function WaitForSingleObjectEx Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long
    
    Private Const FILE_NOTIFY_CHANGE_ATTRIBUTES = &H4
    Private Const FILE_NOTIFY_CHANGE_DIR_NAME = &H2
    Private Const FILE_NOTIFY_CHANGE_FILE_NAME = &H1
    Private Const FILE_NOTIFY_CHANGE_LAST_WRITE = &H10
    Private Const FILE_NOTIFY_CHANGE_SECURITY = &H100
    Private Const FILE_NOTIFY_CHANGE_SIZE = &H8
    
    Private lNotifyHandle As Long
    Private bStop As Boolean
    
    Private Sub Command1_Click()
        Dim lReturn As Long
        
        bStop = False
        lNotifyHandle = FindFirstChangeNotification("C:\Test\", 1, FILE_NOTIFY_CHANGE_FILE_NAME)
        If lNotifyHandle < 1 Then MsgBox "Couldn't get a Notify Handle": Exit Sub
        While Not bStop
            lReturn = WaitForSingleObjectEx(lNotifyHandle, 1, True)
            If lReturn = 0 Then
                Text1.SelText = "Something Changed" & vbCrLf
                Call FindNextChangeNotification(lNotifyHandle)
            End If
            DoEvents
        Wend
        Call FindCloseChangeNotification(lNotifyHandle)
        
    End Sub
    
    Private Sub Command2_Click()
        bStop = True
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        bStop = True
    End Sub
    Regards,

    - Aaron.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width