Results 1 to 2 of 2

Thread: Hidden attribute

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Location
    Minnesota
    Posts
    91

    Hidden attribute

    How can I set a program's hidden attribute so that people dont mess around with it?

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    VB Code:
    1. Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" _
    2.     (ByVal lpFileName As String) As Long
    3.    
    4. Private Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" _
    5.     (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
    6.  
    7. Private Const INVALID_HANDLE_VALUE As Long = -1&
    8. Private Const MAX_PATH As Long = 260&
    9. Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10&
    10. Private Const FILE_ATTRIBUTE_ARCHIVE As Long = &H20&
    11. Private Const FILE_ATTRIBUTE_COMPRESSED As Long = &H800&
    12. Private Const FILE_ATTRIBUTE_HIDDEN As Long = &H2&
    13. Private Const FILE_ATTRIBUTE_NORMAL As Long = &H80&
    14. Private Const FILE_ATTRIBUTE_READONLY As Long = &H1&
    15. Private Const FILE_ATTRIBUTE_SYSTEM As Long = &H4&
    16. Private Const FILE_ATTRIBUTE_TEMPORARY As Long = &H100&
    17.  
    18. 'then
    19. Dim retval As Long 'generic return value
    20.     Dim lngAttr As Long 'file attributes
    21.    
    22.     If Right$(filename, 1) <> vbNullChar Then filename = filename & vbNullChar
    23.    
    24.     'set the hidden bit
    25.     lngAttr = GetFileAttributes(filename)
    26.     retval = SetFileAttributes(filename, lngAttr Or  FILE_ATTRIBUTE_HIDDEN)
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width