|
-
Nov 12th, 2010, 04:51 PM
#1
Thread Starter
New Member
-
Nov 12th, 2010, 05:07 PM
#2
Re: How adapt this code?
What is there to adapt? Simple instead of the path "C:\MyDirectory" put whatever folder you want.
-
Nov 12th, 2010, 05:18 PM
#3
Thread Starter
New Member
Re: How adapt this code?
Hi =) baja yu, If I change the path for mine works fine but only with a folder, if I block other folders and then try to unlock can unlock only one, the others are blocked until you close the application. I need it to work with several folders at the same time =). According to the code would need to create a collection of objects but I have no idea how to do it, if someone could help me to adapt the code I would be most grateful.
-
Nov 12th, 2010, 06:29 PM
#4
Re: How adapt this code?
That code doesn't prevent the folder from being added to or files from being removed/deleted from, it only prevents the folder from being deleted.
With that code, you can solve the collection various ways, like using a simple array instead. However, caching the various file handles to the registry may be a bit challenging for you. Not really sure on the need for the registry either, in this case, other than starting/quitting/re-starting the application during the same windows session.
-
Nov 12th, 2010, 06:46 PM
#5
Thread Starter
New Member
Re: How adapt this code?
 Originally Posted by LaVolpe
That code doesn't prevent the folder from being added to or files from being removed/deleted from, it only prevents the folder from being deleted.
With that code, you can solve the collection various ways, like using a simple array instead. However, caching the various file handles to the registry may be a bit challenging for you. Not really sure on the need for the registry either, in this case, other than starting/quitting/re-starting the application during the same windows session.
So exactly what I performed: starting / Quitting / re-starting the application During The Same windows session. The only problem is I want the application to auto start at boot windows, and lock phase selected folders, without the user starts the program manually. I agree that the problem is how to manage multiple handles at the same time and release all the same way (I do not need to be unlocked one by one, only this:
1. Blockage of all folders and
2. Unlock all folders
I do not know if there is any other method or way to implement this, I searched how to fix my problem for 4 days and I can not do it = ( all the examples use a unique folder not various =(
-
Nov 12th, 2010, 06:57 PM
#6
Re: How adapt this code?
Well, the registry may be a good place to store the folders to lock on startup, but a simple text file may be just as good to start with.
To get your app to start with Windows, you'd have to add it to the Startup folder or appropriately within the registry.
Keep this in mind, the handles you cache are only good until you are logged off; they should be released at that point, but the :dirLock files created will not be deleted until you do that manually. You will also have to deal with keeping your app running if someone switches users on the system; your app may very well close and release the handles (not 100% sure about that).
VB collections are very easy to use, just look at your help files. A collection has some added benefits
1) You can store the path name as each collection item's Key. This way you can easily determine if the folder is already in your collection or not
2) The value of each collection item can be the file handle
3) You can loop thru collections very easily and store locked folder paths to your text file/registry when the app closes
Now the easy question that begs to be answered. Why not use NTFS permissions?
-
Nov 12th, 2010, 07:09 PM
#7
Re: How adapt this code?
Ummm, bad advice. A collection is not ideal. You cannot extract a collection item's key very easily & requires some advanced code to do so. Another option may be to use a array of classes or user-defined types (UDTs), but I'm afraid that may up your learning curve too.
-
Nov 12th, 2010, 07:16 PM
#8
Thread Starter
New Member
Re: How adapt this code?
yes, a little hard to explain jeje =(, look, the code I'm using right now is this (see post # 5) http://www.vbforums.com/showthread.php?t=632590 is very similar to that indicated above, but both give me the same problem of not being able to unlock multiple folders. I am very new in vb6 I have read about collections of objects and the truth could not implement it. NTFS permissions required to add the user name and password of the pc right?, In this case would not be very useful as it is supposed to work without putting any data, just select the folders, lock and unlock = ( but I think it is quite difficult to get something like that for me =(
-
Nov 12th, 2010, 07:33 PM
#9
Re: How adapt this code?
Before anyone continues to offer advice, can you explicitly define both lock & unlock, as it pertains to your project?
-
Nov 12th, 2010, 07:49 PM
#10
Thread Starter
New Member
Re: How adapt this code?
ok, the idea is this:
Lock: Prevents the selected folders (stored in file. Ini) can be deleted, copied, removed or accessed.
Unlock: It allows the user to again have total control over the folders.
The application performs the lock when the user minimizes and placed as an icon in the system tray, when you maximize the application terminates the lock and you can edit your folders. All this while the application is running. When the application is closed any type of lock is canceled.
The idea of the application is to help protect in run-time the access to your private folders from stranger users, that use the same pc and same user session. Combine other simple methods of protection, this is only a part but have not succeeded as I would like, I do not need encryption, only lock and unlock the folders that the user selects. =)
Last edited by jojobb; Nov 12th, 2010 at 07:53 PM.
-
Nov 12th, 2010, 07:52 PM
#11
Re: How adapt this code?
What you are trying to do is not something that can achieved easily, if at all. Is this a project that a teacher assigned to you or did you choose it? In the latter case I'd suggest you pick a different project idea.
-
Nov 12th, 2010, 08:02 PM
#12
Thread Starter
New Member
Re: How adapt this code?
=( is a group project for school, I'm actually a graphic designer and use a little vb6 but very little, for now consider the application as complete as I have not been able to overcome this problem = ( If someone comes up with some code or idea I will be happy to implement it, we still have a week to deliver the project so I have hope =)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|