新建From1(窗体),新建Command1(按钮CommandButton),代码:
Const READONLY = &H1
Const HIDDEN = &H2
Const SYSTEM = &H4
Const ARCHIVE = &H20
Const NORMAL = &H80
Private Declare Function SetFileAttributes Lib "kernel32.dll" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
Private Sub Command1_Click()
Dim attr As Long
Dim ret As Long
attr = READONLY + SYSTEM + HIDDEN
ret = SetFileAttributes(App.Path & "\manongku.txt", attr)
MsgBox ret
End Sub
显示1表示成功。