Page 1 of 1

Folder Hider Hide a folder using VB6 Rate Topic: -----

#1 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 423
  • View blog
  • Posts: 4,131
  • Joined: 25-March 09

Posted 03 January 2010 - 04:17 PM

Useful if you have to hide your DB from user or you want to lock some folder

Using:
FileSystemObject
Require:
Microsoft Scripting Runtime
or
C:\WINDOWS\System32\scrrun.dll

so using attributes of the folder we hide it and by giving it a different name from the one he have it will not be even able to access it from Command Prompt. So here is the code for hiding
Private Sub Command1_Click()
	Dim FS As New FileSystemObject
	Dim F
	Dim strPath As String
		
	strPath = "E:\TestFolder"
	
	Name strPath As strPath & "A"
		
	Set F = FS.GetFolder(strPath & "A")
	
	f.Attributes = -1
End Sub



so lets explain to variable F we send the folder we want to hide. by changing his name it will not be able to access it with command prompt and by setting its attributes to "-1" we make it a system folder so its hidden from windows explorer(works for me on xp, on vista need to refresh the folder but it works).

So here is the code to bring it back :)
Private Sub Command2_Click()
	Dim fs As New FileSystemObject
	Dim f
	Dim strPath As String
	
	strPath = "E:\TestFolder"
	Set f = fs.GetFolder(strPath & "A")
	f.Attributes = 0
	Name strPath & "A" As strPath
End Sub




it is the reverse of the first code by making it 0 we return it to normal and rename it to original name :)

so here it is :)

Attached File(s)



Is This A Good Question/Topic? 2
  • +

Page 1 of 1