Results 1 to 12 of 12

Thread: How can I hook a folder activity like New File Creation or Deletion from vb

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Bangladesh
    Posts
    5

    Question How can I hook a folder activity like New File Creation or Deletion from vb

    Dear ,
    I want to hook a folder to know its activity like folder /file creation or deletion in it. When a file or folder created i recieve a message.
    Also I want to know which folder is open in my computer (Explorer). I want it's full path.
    Hasin Hayder
    web : http://vbsthopoti.cjb.net

  2. #2

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Bangladesh
    Posts
    5
    Strange !
    Not a single one here doesnot know my answer

    Really Strange
    Hasin Hayder
    web : http://vbsthopoti.cjb.net

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    This page should give you some ideas

    http://www.systeminternals.com/ntw2k.../filemon.shtml
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    About 2 years ago I spent 3 months trying to get Windows Explorer to tell me what folder and file it had selected.
    I couldn't find a way to do it (which doesn't mean that it can't be done, but I couldn't find a way).

    Instead I had to implement right click / right click and Send To / drag and drop from WinExp to my application to allow my app to know which file was selected.

  5. #5
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    Just as we have Keyboard hook and message hook, well do we
    have a folder or file hook?
    I'm not so good in system hooking but speaking of message hook
    perhaps u should monitor for messages regarding file and folder
    manipulation?
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  6. #6
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    Quoted by Sysinternals
    For the Windows 9x driver, the heart of Filemon is in the virtual device driver, Filevxd.vxd. It is dynamically loaded, and in its initialization it installs a file system filter via the VxD service, IFSMGR_InstallFileSystemApiHook, to insert itself onto the call chain of all file system requests. On Windows NT the heart of Filemon is a file system driver that creates and attaches filter device objects to target file system device objects so that Filemon will see all IRPs and FastIO requests directed at drives.

    When Filemon sees an open, create or close call, it updates an internal hash table that serves as the mapping between internal file handles and file path names. Whenever it sees calls that are handle based, it looks up the handle in the hash table to obtain the full name for display. If a handle-based access references a file opened before Filemon started, Filemon will fail to find the mapping in its hash table and will simply present the handle's value instead.
    VxDs!!!
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    It's possible, FindFirstChangeNotification API calls handles this, however, it would most likely need to be run as a seperate thread, so it wouldn't halt execution of your VB program. If you're using VB.NET, you could create another thread to do this... for VB6 perhaps you could incorporate the code in the first example into a DLL.... at least I think it has to be run in a seperate thread...

    http://msdn.microsoft.com/library/de...ctory_tree.asp

    http://msdn.microsoft.com/library/de...tification.asp
    Last edited by nemaroller; Nov 6th, 2002 at 09:30 AM.

  8. #8
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    yea nemaroller I've used that method b4 but frankly even if the
    folder I'm monitoring doesn't change it still keep on buzz me with
    the notification.

    So since u mentioned running in another thread perhaps this
    will help me a bit, perhaps not(VB unstable during Multi-
    Threading) haha
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  9. #9
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I would guess it had to do with the flag you used.... perhaps FILE_NOTIFY_CHANGE_ATTRIBUTES or FILE_NOTIFY_CHANGE_SIZE or FILE_NOTIFY_CHANGE_LAST_WRITE , any change in any of these would fire it off....

    Now, I haven't had a need to use the functions so I can't tell you exactly how I would do it... but then you must also consider
    FndNextChangeNotification

  10. #10
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    ok nemaroller, I went to Microsoft MSDN site and convert the
    C++ codes to VB codes, and I've attached the VB src codes.
    It's quite a complete file monitor.

    BTW, anyone knows how to get the filename(s) or foldername(s)
    involved when such file changing event occured?
    Attached Files Attached Files
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  11. #11
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Holy Crap good job...!!!!! I'm adding this one to my library... again, excellent...
    Last edited by nemaroller; Nov 6th, 2002 at 11:37 PM.

  12. #12

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Bangladesh
    Posts
    5
    Thanks a lot jian. A great done!
    Hasin Hayder
    web : http://vbsthopoti.cjb.net

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