Folder restricted access...

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Folder restricted access...

Post by Kwai chang caine »

Hello at all

I want to know, if is possible to launch a exe when we open a folder.
A little bit like a boot in a floppy. :roll:

I would like to make a programme of security that restricts the reading of a repertoire.
If is the good user, that's all right, else a messagerequester "You are not autorised to acces at this folder" :D

A precision, i'm not the administrator of the computer and the server too. :?
But i have the right to use a folder in read and write.
I want just to protect a few directories of other users.

This is there hard for request, i know. :oops:

I have a small hope, because this forum is used by gods 8)

I wish you a very good day.
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Nobody can help me ? :cry:

For this question or other POST that looks like it :

http://www.purebasic.fr/english/viewtopic.php?t=30781

Thanks in advance for your help
ImageThe happiness is a road...
Not a destination
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

It's easy enough to get the folder's window title and launch an exe (that's
one very basic protection) but it's not 100% foolproof and users can still
access folder contents through DOS prompts and other apps. What you're
asking for is not easily done, and has been discussed in other posts here.

The closest I've seen (which is still not 100% foolproof) is this post:

http://www.purebasic.fr/english/viewtopic.php?t=23493
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Yeeeeess!
I am not alone in the world :lol:

Hello PB, happy to talk to you 8)
Did you find a way for your research?

And my idea of changing files in a folder?
What do you think of that? :roll:

Perhaps, if a folder was changed in the file, he could not open or it is not readable ?
But NETMAESTRO told me, that it was possible :shock:
But it does not say I was more :cry:

http://www.purebasic.fr/english/viewtop ... 761#229761

I am so sad :cry:
He must be tired of my questions :oops:
ImageThe happiness is a road...
Not a destination
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Hi KCC,

I haven't found a way to lock a folder that works in all situations. :(

The closest alternative I've found is to just lock all files in a folder.
Run the following code, and DON'T close the MessageRequester.
It will lock all files in your Internet Explorer folder as long as the
MessageRequester is open or the app is running. Hope this helps.

Code: Select all

Global lockedfiles
Global Dim lockedfiles$(9999999)
Global Dim lockedfileid(9999999)

Procedure GetFolderContents(dir$,dir)
  tmp=dir+1
  If ExamineDirectory(tmp,dir$,"*.*")
    While NextDirectoryEntry(tmp)
      type=DirectoryEntryType(tmp)
      name$=DirectoryEntryName(tmp)
      If type=#PB_DirectoryEntry_File
        lockedfiles+1 : lockedfiles$(lockedfiles)=dir$+name$
      Else
        If name$<>"." And name$<>".."
          GetFolderContents(dir$+name$+"\",tmp)
        EndIf
      EndIf
    Wend
    FinishDirectory(tmp)
  EndIf
EndProcedure

lockedfiles=0 : GetFolderContents("C:\Program Files\Internet Explorer\",0)

For a=1 To lockedfiles : lockedfileid(a)=OpenFile_(lockedfiles$(a),@ofs.OFSTRUCT,#OF_SHARE_DENY_READ) : Next

RunProgram("C:\Program Files\Internet Explorer\")

a$="Contents of your Internet Explorer folder are locked."+#CR$
a$+"Try to run the app, or any of its files, and then click"+#CR$
a$+"the OK button below to unlock them again."
MessageRequester("Locked",a$)

For a=1 To lockedfiles : CloseHandle_(lockedfileid(a)) : Next
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Thank you PB for sharing your code 8)
It's a good alternative for my problem pending.

I hope a GOD interest to this POST and, with his divine finger touch me for i see the solution :D

Thanks you very much for your help.
I wish you a good day
ImageThe happiness is a road...
Not a destination
Post Reply