Autor Beitrag
sdavis
Hält's aus hier
Beiträge: 3

Win XP

BeitragVerfasst: Di 16.11.04 12:34 
Hi aLL,

Somebody know a mode to turn invisible or inacessible a windows folder ? I need protect some folders from users.


Thanks,
Sammy Davis


Moderiert von user profile iconTino: Topic aus VCL (Visual Component Library) verschoben am Mi 17.11.2004 um 10:35
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 16.11.04 12:52 
Hello!

Does this only have to be applied when running a delphi app, or does this restriction have to be general? If it was the last, just revoke the rights for this folder from the user(-group) as it is possible with WIN XP / WIN 2000 / Win NT.

Cu,
Udontknow
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 16.11.04 12:57 
Hi Sammy,

You can use the API function Suche im MSDN "SETFILEATTRIBUTES" like this:SetFileAttributes('C:\My Folder', FILE_ATTRIBUTE_HIDDEN);This will set the folder's attribute to "hidden" and corresponds to changing the file attribute via the File Properties Dialog in the Windows Explorer and choosing "Apply changes to this folder only" (don't know if the translation is correct, I have a German windows). The choice between applying the changes to the selected folder only and applying them to all files and folders contained is given in Windows XP (don't know about other Versions).
To apply the hidden-attribute also to the contained files, you have to go through all the files recursively (Serach for files recursively, sorry, it's German) and call SetFileAttributes() with every file found. But normally, this is not neccessary, though, because if you can't see the folder in the Explorer, you can't open it and will never see the files in the folder, even if they are not hidden.
But keep in mind that hiding files is not a very secure mechanism and that one could easily access the hidden folders if the name is known. And there are even possibilities to get the name, either programmatically oder via other tools (i.e. Total Commander is able to show invisible files, even for non-admin accounts, the Windows Explorer has the same feature but I don't know if only the admin is able to activate it).

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
sdavis Threadstarter
Hält's aus hier
Beiträge: 3

Win XP

BeitragVerfasst: Di 16.11.04 13:38 
Udontknow hat folgendes geschrieben:
Hello!

Does this only have to be applied when running a delphi app, or does this restriction have to be general? If it was the last, just revoke the rights for this folder from the user(-group) as it is possible with WIN XP / WIN 2000 / Win NT.

Cu,
Udontknow




I need when only running my delphi app.



Thanks.
sdavis Threadstarter
Hält's aus hier
Beiträge: 3

Win XP

BeitragVerfasst: Di 16.11.04 13:48 
tommie-lie hat folgendes geschrieben:
Hi Sammy,

You can use the API function Suche im MSDN "SETFILEATTRIBUTES" like this:SetFileAttributes('C:\My Folder', FILE_ATTRIBUTE_HIDDEN);This will set the folder's attribute to "hidden" and corresponds to changing the file attribute via the File Properties Dialog in the Windows Explorer and choosing "Apply changes to this folder only" (don't know if the translation is correct, I have a German windows). The choice between applying the changes to the selected folder only and applying them to all files and folders contained is given in Windows XP (don't know about other Versions).
To apply the hidden-attribute also to the contained files, you have to go through all the files recursively (Serach for files recursively, sorry, it's German) and call SetFileAttributes() with every file found. But normally, this is not neccessary, though, because if you can't see the folder in the Explorer, you can't open it and will never see the files in the folder, even if they are not hidden.
But keep in mind that hiding files is not a very secure mechanism and that one could easily access the hidden folders if the name is known. And there are even possibilities to get the name, either programmatically oder via other tools (i.e. Total Commander is able to show invisible files, even for non-admin accounts, the Windows Explorer has the same feature but I don't know if only the admin is able to activate it).



I Know the "Alfa File Protector", www.alfasp.com. It do i need, but is very expensive for me.
I looking for another mode. My app is a cyber caffe and i need block folders. E.g. Internet Explorer have acces to folder in adress bar. It's a mode to users change or delete files.


Thomas, thanks by attention .
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 16.11.04 14:03 
As far as I can see from the Alfa Homepage, AFP uses some driver tricks to deny access to certain files or folders, which may be quite difficult to implement.
but maybe windows itself brings what you need. If you don't want a user to write to files you are using while you use it, simply open them in exclusive mode (or read/write). As long as you have the file open, nobody can write to it, though reading is still possible.
If you want to deny access to certain users, but not to the system admin (for example), then you can use the File Rights Management provided by Windows NT on NTFS-formatted volumes. For instance you can deny user XYZ to read specific files. But those attributes has to be set by the file owner (or admin) and your application usually runs as the same user who startet it. So this may not be helpful if you want to protect files from the same user who startet your application.

If your user should not delete the files when your application is shut down (i.e. if they contain customizations, settings, a.s.o.), I would not deny it to the user. It is his fault if he deletes delicate files, if I log in as local administrator and delete explorer.exe, it is my fault that Windows won't start properly after the next reboot. Just say in the readme file that these files belong to your application, what they contain and that the application won't work in the desired way if they are deleted.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert