Site Admin

Joined: 06 Jul 2007
Posts: 129
Location: india
|
|
There are many softwares which you can use to hide the files on ur
Windows machine. So wot they do actully? No magic, ofcourse.
Windows gives EVERY file or folder certain flags called ‘Attributes’.
These attributes tell the system what can and cannot be done with the
file.
For example, the Read Only attribute tells the system to not allow
changes to the file.
Files or folders with the combination of Hidden and System attributes
are considered "Super Hidden" by Windows.
These super hidden files or folders cannot be seen by simply making
hidden folders visible.
And that is wot these folder hiding softwares do.
File attribute for a system file is 4. And file attribute for a hidden
file is 2. So, in order to make a superhidden file,
we need to set the attribute of a file as 6 (=4+2).
And for that, We need to make use of a API, named SetFileAttributes.
For example, i want to hide (or super-hide) a file c:omk.c. So i
write the code (in VB.Net) as follows:
Code:
Private Declare Function SetFileAttributes Lib "kernel32" Alias
"SetFileAttributesA" (ByVal lpFileName As String, ByVal
dwFileAttributes As Integer) As Integer
Const HMCHIDDEN As Short = 2
Const HMCSYSTEM As Short = 4
Const HMCNORMAL As Short = 128
Const HMCSUPERHIDDEN As Integer = HMCHIDDEN + HMCSYSTEM
Public SelectedFile As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim returnvalue As Object
SelectedFile = "c:omk.c"
returnvalue = SetFileAttributes(SelectedFile, HMCSUPERHIDDEN)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim returnvalue As Object
SelectedFile = "c:omk.c"
returnvalue = SetFileAttributes(SelectedFile, HMCNORMAL)
End Sub |
_________________ Avinash
|
|