Hi Masters...
I want to hide folder or drive with vb6, but i don't have idea how to do this.
any one know how to solved this?

Please Help.
Any suggestion will appreciated much.

Recommended Answers

All 11 Replies

Do you use any control or what?

Where will other drives or folders be shown?

Little info little help. :P

>> Do you use any control or what?
No, i don't.
I just wanna to hide or unhide drive or folder.
Ex : D:\test (Hide folder test on drive D)...
Any suggestion...

Using Api function to hide drive

try this following code to hide folder

Private Sub Form_Load()
Dim FileSys, FolderPath
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set FolderPath = FileSys.GetFolder("D:\test")
FolderPath.Attributes = -1
End Sub

to unhide set attributes = 0

commented: Wonderful code +1

Thx Jx_man, your code worked nice.
one problem again, how to hide drive?
there are another ways to hide drive without using API function?

Any suggestion...

>>There are another ways to hide drive without using API function?
Yes, with add key on your registry...
Add module :

Public Sub CreateKey(ayun As String, Value As String)
Dim b As Object
On Error Resume Next
Set b = CreateObject("wscript.shell")
b.RegWrite ayun, Value
End Sub

Public Sub CreateIntegerKey(ayun As String, Value As Integer)
Dim b As Object
On Error Resume Next
Set b = CreateObject("wscript.shell")
b.RegWrite ayun, Value, "REG_DWORD"

End Sub
'Delete registry key
Public Sub DeleteKey(Value As String)
Dim b As Object
On Error Resume Next
Set b = CreateObject("Wscript.Shell")
b.RegDelete Value
End Sub

This following code will hide drive D:\

Private Sub Command1_Click()
CreateIntegerKey "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Nodrives", 8
End Sub

Restart or logoff to know it works or not
This is value of key :
C = 4
D = 8
E = 16
F = 32
...
C and D = 4 + 8 = 12
C and E = 4 + 16 = 20
D and E = 8 + 16 = 24
....
C and D and E = 4 + 8 + 16 = 28
....

commented: Really Great code +1

wow, thank you Jx_Man.
It worked, but i must logoff or restart to see the result of hiding drive.

There are anyone know another way to hide without logoff or restart computer.

its all i know...
maybe other members have different ways

how i unhide my drive. now my drive d is hide. so please help me

use 0 for unhide

Private Sub Command1_Click()
Dim FileSys, FolderPath
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set FolderPath = FileSys.GetFolder("E:\Locked")

FolderPath.Attributes = -1
End Sub

Private Sub Command2_Click()
Dim FileSys, FolderPath
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set FolderPath = FileSys.GetFolder("E:\Locked")
FolderPath.Attributes = -0
End Sub

Great Poject but still finds hidden folder if searched for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.