CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2001
    Posts
    29

    File Notification

    I have a network directory that occasionaly gets a file in it. I want to test the path for "\\servername\path" and have it noteify if any file is in it and then do something. The problem i have been having is that i never know what the *.* could be.

    Thanks
    ~bml


  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: File Notification


    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_SIZE = &H8
    private Const FILE_NOTIFY_CHANGE_LAST_WRITE = &H10
    private Const FILE_NOTIFY_CHANGE_SECURITY = &H100
    private Const FILE_NOTIFY_CHANGE_ALL = &H4 Or &H2 Or &H1 Or &H8 Or &H10 Or &H100
    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 FindCloseChangeNotification Lib "kernel32" (byval hChangeHandle as Long) as Long
    private Declare Function FindNextChangeNotification Lib "kernel32" (byval hChangeHandle as Long) as Long
    private Declare Function WaitForSingleObject Lib "kernel32" (byval hHandle as Long, byval dwMilliseconds as Long) as Long
    private Declare Function ResetEvent Lib "kernel32" (byval hEvent as Long) as Long
    private Sub Form_Load()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: [email protected]
    Dim Ret as Long
    'set the notification hook
    Ret = FindFirstChangeNotification("C:\", &HFFFFFFFF, FILE_NOTIFY_CHANGE_ALL)
    'Wait until the event is triggered
    WaitForSingleObject Ret, &HFFFFFFFF
    MsgBox "Event Triggered for the first time"
    'Reactivate our hook
    FindNextChangeNotification Ret
    'Wait until the event is triggered
    WaitForSingleObject Ret, &HFFFFFFFF
    MsgBox "Event Triggered for the second time"
    'Remove our hook
    FindCloseChangeNotification Ret
    End Sub





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

Featured