CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Apr 2009
    Posts
    9

    Protect Directories from Access

    Hi, I am new to Codeguru, but I hope I am right, posting my topic here.
    I would like to know, if anyone knows how I can protect Directories.
    If programm A for example, wants to delete a file in a folder, is it possible for (my) programm B to detect that action and prevent it?
    I want to protect certain areas of my Folders from access, some prorgamms might want to have.
    I hope you understand my problem.

    Thank you,

    Anno1989

  2. #2
    Join Date
    Apr 2009
    Posts
    9

    Re: Protect Directories from Access

    Is there nobody here, who knows how to solf this?
    I found this:
    FindFirstChangeNotification
    ReadDirectoryChangesW

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Protect Directories from Access

    Quote Originally Posted by Anno1989 View Post
    I found this:
    FindFirstChangeNotification
    ReadDirectoryChangesW
    These ones use only for monitoring.
    When you'll get a notification, the changes are already done, so you cannot "prevent" anything.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Apr 2009
    Posts
    14

    Re: Protect Directories from Access

    What you need to learn is how to implement "Hooks" and how to work with Dynamic Link Library (DLL) files. Hooks are created by programs to monitor many types of "actions" such as the co-ordinates of the mouse or what key is being pressed on the keyboard (whether or not your window is active), mind you, if you just need to monitor the mouse or what key is being pressed on the keyboard then you won't need to know how to use DLLs, but in this situation you will need to.

    To tell the truth I'm just taking a guess here, I don't know if this is what you're looking for. I've only ever used hooks for the mouse and keyboard, which was pretty exciting . But even so, if you want to monitor actions going on in a computer using hooks is your best bet, which is why I bothered to tell you.

  5. #5
    Join Date
    Dec 2008
    Posts
    114

    Re: Protect Directories from Access

    Message Hooks are irrelevant here.
    Use CHH for example (Google groups, Win32 , plenty of samples)

  6. #6
    Join Date
    Apr 2009
    Posts
    14

    Re: Protect Directories from Access

    I didn't exactly say that message hooks were the answer, there are moer than just three you know. I assume you meant that all hooks are irrelevant, in that case, are you sure? because I can't really see any other way of doing it... unless you create a service that is.

  7. #7
    Join Date
    Apr 2009
    Posts
    9

    Re: Protect Directories from Access

    Dont know what CHH is and dont get any good results, do you have a link?
    So it is not possible with the pure winapi functions documentated in the msdn?
    So when I use hooks, can I really stop any other application?

    Or is there even a methode, windows lets me interfere in File actions anyway?
    Maybe I search for something what is not implemented in windows.^^

    Edit: Took to long to post. A service? I already created a simple service, but what is the difference between a service and a normal programm.
    When my programm runs successfully, I assume I would make a service of it anyway.
    Last edited by Anno1989; April 23rd, 2009 at 04:12 PM.

  8. #8
    Join Date
    Apr 2009
    Posts
    14

    Re: Protect Directories from Access

    I'm sorry Anno, all I know about services is that when it comes to power they are even above programs, because they can run before you even log into Windows. That's how defragmenting programs defrag your computer before you log-in.

    When it comes to programs, using hooks is pretty much the most power you can control, although there could be other things that I don't know about.

    I really recommend you research services and hooks... but don't take my word for anything I ain't no pro.

  9. #9
    Join Date
    Apr 2004
    Posts
    102

    Re: Protect Directories from Access

    Quote Originally Posted by Anno1989 View Post
    Hi, I am new to Codeguru, but I hope I am right, posting my topic here.
    I would like to know, if anyone knows how I can protect Directories.
    If programm A for example, wants to delete a file in a folder, is it possible for (my) programm B to detect that action and prevent it?
    I want to protect certain areas of my Folders from access, some prorgamms might want to have.
    I hope you understand my problem.

    Thank you,

    Anno1989
    You can use Microsoft Detours to prevent a file from being deleted. Or possibly back up the file before the program deletes the file.

  10. #10
    Join Date
    Apr 2009
    Posts
    14

    Re: Protect Directories from Access

    I think its pretty obvious he wants to know how to do it programmaticly .

  11. #11
    Join Date
    Apr 2009
    Posts
    9

    Re: Protect Directories from Access

    Yes, I already thought about backing the File up and replacing it, after it is deleted.
    But, I can hardly backup a larger Directory.
    Yes, I want to know, if there is a way, to do this programmatically.
    I also found change journals, that report changes on volumes.
    I think I look at this, cause ReadDirectoryChangesW() does not return in my application.^^
    Maybe I find something when I read the File Services Section of msdn in System Services.
    Or has anyone a better solution?^^

    Thank you for your help so far.

  12. #12
    Join Date
    Apr 2009
    Posts
    14

    Re: Protect Directories from Access

    Well I have though of one way of doing it... but it isn't really recommended. What you could do is periodically search for the delete box, by this I mean that you could use certain functions to search for its class ID... once you find it just close it or programmaticly hit the "cancel" button.

    Its been a while since I did any sort of programming that's why I can't list any functions... wait... I just remembered FindWindow, it take in the class ID and another parameter which I forgot, you can use this.

    Ther only reason I posted this approach was because it seems this is the only solution that anyone can come up with for you on CodeGuru... honestly I'm quite suprised peope havn't said something.... I was sure there'd be atleast one.

    Just to let you know, it is possible to do it the "propper" way. I mean just look at anti-viruses right? They can stop a lot of malicious activities from taking place. I have no idea how they do it though.... sorry.

  13. #13
    Join Date
    Apr 2009
    Posts
    9

    Re: Protect Directories from Access

    Right, I thought there would be more people who can help, too, thats why I came to codeguru. ^^
    But if nobody helps, the only two reasons I can think of are, wrong sub forum, or that there isnt really a good way to solve this...
    Searching for the delete Box?
    I dont aim to protect myself against Apps, who ask for deleting or something like that. I want to get a full protection against Apps who dont show me, that they delete something, else it wouldn't make much sense I think...
    Last edited by Anno1989; April 29th, 2009 at 11:02 AM.

  14. #14
    Join Date
    Nov 2006
    Posts
    1,611

    Re: Protect Directories from Access

    Google for Volume Shadow Services.

    What you're looking for IS a bit tricky, but it is possible.

    The Volume Shadow Service may get you there, it somewhat depends on the nature of your application requirements.

    There's lots to ask about the scenario, too.

    Where did the file(s) come from that you need to protect?

    Right, I thought there would be more people who can help, too, thats why I came to codeguru.
    ...and you'll find there ARE people here from diverse industries, of considerable experience, and often very busy!

    We volunteer, so it's not always fast service.
    If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).

  15. #15
    Join Date
    Apr 2009
    Posts
    9

    Re: Protect Directories from Access

    Sorry, if you misunderstood me, I did not meant to blame anybody or complain.
    Mhh I want to protect my windows Directory on the system partition, maybe the whole system partition.
    Just, that no programm, that simply deletes some files there can kill my Computer...
    And of course I want to know which programm wants to operate there.
    Is that possible?

Page 1 of 2 12 LastLast

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