网站首页  词典首页

请输入您要查询的函数:

 

术语 setfileattributes
释义 SetFileAttributes
语法:
C++
BOOL WINAPI SetFileAttributes(
__in LPCTSTR lpFileName,
__in DWORD dwFileAttributes
);
SetFileAttributes函数
设置一个文件或目录的属性。
作为一个要执行此操作的事务操作,请使用SetFileAttributesTransacted功能。
参数
lpFileName [in]
该文件的名称属性设置。
在此函数的ANSI版本,名称被限制为MAX_PATH字符。为了延长此限制,以32,767宽字符,调用的功能和前面加上“\\ Unicode版本\\?\\”的路径。有关更多信息,请参阅文件名,路径和命名空间。
dwFileAttributes [in]
文件属性设置的文件。
此参数可以是一个或多个值,结合使用按位或运算符。但是,所有其他值覆盖FILE_ATTRIBUTE_NORMAL。
并非所有的属性都支持这个功能。有关详细信息,请参见备注部分。
以下是受支持的属性值的列表。
ValueMeaning
FILE_ATTRIBUTE_ARCHIVE
32(0x20)的文件或目录是一个存档文件或目录。应用程序通常使用这个属性来庆祝备份或删除的文件。
FILE_ATTRIBUTE_HIDDEN
2(0x2)的文件或目录是隐藏的。它不包括在一个普通的目录清单。
FILE_ATTRIBUTE_NORMAL
128(0x80)的文件不具有其他的属性。此属性是有效的,只有单独使用。
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
8192 (0x2000)The file or directory is not to be indexed by the content indexing service.
FILE_ATTRIBUTE_OFFLINE
4096(0x1000)在文件中的数据是不是可以立即。此属性指示该文件的数据是实际搬迁到脱机存储。该属性是使用远程存储,这是分级存储管理软件。应用程序不应随意更改此属性。
FILE_ATTRIBUTE_READONLY
1(0x1),一个是只读文件。应用程序可以读取该文件,但不能写入或删除它。此属性不是荣幸的目录。有关更多信息,请参见:“您不能查看或更改只读或系统属性在Windows Server 2003文件夹在Windows XP,或Windows Vista中,”。
FILE_ATTRIBUTE_SYSTEM
4(0x4)的文件或目录的操作系统使用的一部分,或使用专用。
FILE_ATTRIBUTE_TEMPORARY
256(0x100)甲正在用于临时存储文件。文件系统避免写数据传回的海量存储如果有足够的缓存内存可用,因为通常,一个应用程序删除临时文件后,关闭句柄。在这种情况下,系统可以完全避免写数据。否则,数据被写入处理后关闭。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
下表描述了如何设置不能设置使用SetFileAttributes属性。有关的所有文件的属性值和说明的完整列表,请参阅文件属性。
AttributeHow设置
FILE_ATTRIBUTE_COMPRESSED
0x800To设置文件的压缩状态,请使用与FSCTL_SET_COMPRESSION操作DeviceIoControl函数。
FILE_ATTRIBUTE_DEVICE
0x40Reserved,不要使用。
FILE_ATTRIBUTE_DIRECTORY
0x10Files无法转换成目录。要创建一个目录,请使用CreateDirectory或CreateDirectoryEx功能。
FILE_ATTRIBUTE_ENCRYPTED
0x4000To创建一个加密文件,使用与FILE_ATTRIBUTE_ENCRYPTED属性CreateFile函数。转化为加密文件,使用功能与EncryptFile现有文件。
FILE_ATTRIBUTE_REPARSE_POINT
0x400To联想到一个文件或目录的分析点,使用的FSCTL_SET_REPARSE_POINT操作DeviceIoControl函数。
FILE_ATTRIBUTE_SPARSE_FILE
0x200To设置文件的稀疏属性,使用与FSCTL_SET_SPARSE操作DeviceIoControl函数。
交易业务
如果打开一个文件进行修改的交易,没有其他线程可以打开文件进行修改,直到提交事务。因此,如果一个事务处理线程打开文件的第一,任何试图修改前的事务被提交文件的后续线程收到共享冲突。如果非交易线程修改线程交易之前,该文件不,该文件仍处于打开状态时,交易试图打开它,交易收到错误ERROR_TRANSACTIONAL_CONFLICT。
实例
有关示例,请参见检索和更改文件属性。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesSetFileAttributesW(Unicode)和SetFileAttributesA(ANSI)的
参见
文件属性
文件管理函数
GetFileAttributes
SetFileAttributesTransacted
符号链接
交互式NTFS
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==SetFileAttributes Function
Sets the attributes for a file or directory.
To perform this operation as a transacted operation, use the SetFileAttributesTransacted function.
Syntax
C++
BOOL WINAPI SetFileAttributes(
__in LPCTSTR lpFileName,
__in DWORD dwFileAttributes
);
Parameters
lpFileName [in]
The name of the file whose attributes are to be set.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\\\?\\" to the path. For more information, see File Names, Paths, and Namespaces .
dwFileAttributes [in]
The file attributes to set for the file.
This parameter can be one or more values, combined using the bitwise-OR operator. However, all other values override FILE_ATTRIBUTE_NORMAL.
Not all attributes are supported by this function. For more information, see the Remarks section.
The following is a list of supported attribute values.
ValueMeaning
FILE_ATTRIBUTE_ARCHIVE
32 (0x20)A file or directory that is an archive file or directory. Applications typically use this attribute to mark files for backup or removal.
FILE_ATTRIBUTE_HIDDEN
2 (0x2)The file or directory is hidden. It is not included in an ordinary directory listing.
FILE_ATTRIBUTE_NORMAL
128 (0x80)A file that does not have other attributes set. This attribute is valid only when used alone.
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
8192 (0x2000)The file or directory is not to be indexed by the content indexing service.
FILE_ATTRIBUTE_OFFLINE
4096 (0x1000)The data of a file is not available immediately. This attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, which is the hierarchical storage management software. Applications should not arbitrarily change this attribute.
FILE_ATTRIBUTE_READONLY
1 (0x1)A file that is read-only. Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories. For more information, see "You cannot view or change the Read-only or the System attributes of folders in Windows Server 2003, in Windows XP, or in Windows Vista".
FILE_ATTRIBUTE_SYSTEM
4 (0x4)A file or directory that the operating system uses a part of, or uses exclusively.
FILE_ATTRIBUTE_TEMPORARY
256 (0x100)A file that is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data is written after the handle is closed.

Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
The following table describes how to set the attributes that cannot be set using SetFileAttributes. For a complete list of all file attribute values and their descriptions, see File Attributes .
AttributeHow to Set
FILE_ATTRIBUTE_COMPRESSED
0x800To set a file's compression state, use the DeviceIoControl function with the FSCTL_SET_COMPRESSION operation.
FILE_ATTRIBUTE_DEVICE
0x40Reserved; do not use.
FILE_ATTRIBUTE_DIRECTORY
0x10Files cannot be converted into directories. To create a directory, use the CreateDirectory or CreateDirectoryEx function.
FILE_ATTRIBUTE_ENCRYPTED
0x4000To create an encrypted file, use the CreateFile function with the FILE_ATTRIBUTE_ENCRYPTED attribute. To convert an existing file into an encrypted file, use the EncryptFile function.
FILE_ATTRIBUTE_REPARSE_POINT
0x400To associate a reparse point with a file or directory, use the DeviceIoControl function with the FSCTL_SET_REPARSE_POINT operation.
FILE_ATTRIBUTE_SPARSE_FILE
0x200To set a file's sparse attribute, use the DeviceIoControl function with the FSCTL_SET_SPARSE operation.

Transacted Operations
If a file is open for modification in a transaction, no other thread can open the file for modification until the transaction is committed. So if a transacted thread opens the file first, any subsequent threads that try modifying the file before the transaction is committed receives a sharing violation. If a non-transacted thread modifies the file before the transacted thread does, and the file is still open when the transaction attempts to open it, the transaction receives the error ERROR_TRANSACTIONAL_CONFLICT.
Examples
For an example, see Retrieving and Changing File Attributes .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesSetFileAttributesW (Unicode) and SetFileAttributesA (ANSI)
See Also
File Attributes
File Management Functions
GetFileAttributes
SetFileAttributesTransacted
Symbolic Links
Transactional NTFS
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365535(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:21:10