VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Get & set a file's attributes

Timothy Pew  (3 Submissions)   Files/File Controls/Input/Output   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

Sets a file's attributes. With this you can create archive, hidden, normal,
read-only, and system files.

Inputs
FullFilePath is a string containing the path and filename of a file. FileAttributes is a long integer that contains the value to set as the file's attributes. Use the constants listed below to set this. (SetAttributes only)

Assumes
The default for this function is to set the file's attributes to "archive", which is the standard type of file. To set more than one attribute for a file use the "or" statement. I.E.- FILE_ATTRIBUTE_READONLY or FILE_ATTRIBUTE_HIDDEN. Test for a certain attribute like this: If (GetAttribute And attributeconstant) <> 0 then GetAttribute = attribute defined by constant.

Returns
SetAttributes returns true (1) if successful, otherwise it returns false (0). GetAttributes returns the attributes of FullFilePath

Side Effects
The FILE_ATTRIBUTE_NORMAL (&H80) attribute use to create attribute-less files CAN NOT be combined with any other attribute.

API Declarations
Declare Function SetFileAttributes Lib "kernel32.dll" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
Declare Function GetFileAttributes Lib "kernel32.dll" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long

Rate Get & set a file's attributes (3(3 Vote))
Get & set a file's attributes.bas

Get & set a file's attributes Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters