Win32 API calls for Directory attribute modifications

Does any one know which WIN32 API call(s) I can use to change attribs
(read-only, hidden, etc.) on a directory entry? When I use
“SetFileAttributes” in Win2k, it changes the dir to a file!

Thanks - Greg


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

According to my API documentation on SetFileAttributes…

“The following table describes how to set the attributes that cannot be set using SetFileAttributes.”

"FILE_ATTRIBUTE_DIRECTORY Files cannot be converted into directories. To create a directory, use the CreateDirectory or
CreateDirectoryEx function. "

So it appears, at least at first glance, that you have found a bug in SetFileAttributes.

CreateDirectory and CreateDirectoryEx don’t appear to take parameters that allow you to specify file attributes.

From “CreateFile” documentation…

"An application cannot create a directory with CreateFile; it must call CreateDirectory or CreateDirectoryEx to create a directory.

Windows NT/2000 or later: You can obtain a handle to a directory by setting the FILE_FLAG_BACKUP_SEMANTICS flag. A directory handle
can be passed to some functions in place of a file handle.

Some file systems, such as NTFS, support compression or encryption for individual files and directories. On volumes formatted for
such a file system, a new directory inherits the compression and encryption attributes of its parent directory.

You cannot use the CreateFile function to set a directory’s compression state. Use the DeviceIoControl function to set a directory’s
compression state. "

I think the second statement of those four is your best lead. Try to open the directory with OpenFile, then pass the handle you get
back to SetFileAttributes, and see if that does what you want. Hopefully, SetFileAttributes is one of those “some” functions.

HTH,

ERX

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@filetek.com
Sent: Thursday, September 13, 2001 9:53 AM
To: NT Developers Interest List
Subject: [ntdev] Win32 API calls for Directory attribute modifications

Does any one know which WIN32 API call(s) I can use to change attribs
(read-only, hidden, etc.) on a directory entry? When I use
“SetFileAttributes” in Win2k, it changes the dir to a file!

Thanks - Greg


You are currently subscribed to ntdev as: xxxxx@spinnakernet.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com