怎样用c++修改文件属性?
我如果要把d:\a.txt改成系统隐藏怎么办?是用SetFileAttributes吗?介绍一下吧,谢谢我想要系统属性+隐藏属性怎么弄啊...
我如果要把d:\a.txt 改成系统隐藏
怎么办?
是用SetFileAttributes 吗?介绍一下吧,谢谢
我想要 系统属性+隐藏属性怎么弄啊 展开
怎么办?
是用SetFileAttributes 吗?介绍一下吧,谢谢
我想要 系统属性+隐藏属性怎么弄啊 展开
1个回答
展开全部
用的时候
f=fopen("1.dat","w");
SetFileAttributes("1.dat", FILE_ATTRIBUTE_HIDDEN);
系统是这个 FILE_ATTRIBUTE_SYSTEM
隐藏是这个 FILE_ATTRIBUTE_HIDDEN
这种问题你去看 msdn 帮助文档就行了。给你贴出来帮助
函数原型
BOOL SetFileAttributes(
LPCTSTR lpFileName,
DWORD dwFileAttributes
);
参数:
lpFileName [in] Pointer to a string that specifies 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 Naming a File.
Windows Me/98/95: This string must not exceed MAX_PATH characters.dwFileAttributes [in] File attributes to set for the file. This parameter can be one or more of the following values. However, all other values override FILE_ATTRIBUTE_NORMAL.
属性:
Attribute Meaning
FILE_ATTRIBUTE_ARCHIVE The file is an archive file. Applications use this attribute to mark files for backup or removal.
FILE_ATTRIBUTE_HIDDEN The file is hidden. It is not included in an ordinary directory listing.
FILE_ATTRIBUTE_NORMAL The file has no other attributes set. This attribute is valid only if used alone.
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED The file will not be indexed by the content indexing service.
FILE_ATTRIBUTE_OFFLINE The data of the file is not immediately available. This attribute indicates that the file data has been physically moved to offline storage. This attribute is used by Remote Storage, the hierarchical storage management software. Applications should not arbitrarily change this attribute.
FILE_ATTRIBUTE_READONLY The file is read-only. Applications can read the file but cannot write to it or delete it.
FILE_ATTRIBUTE_SYSTEM The file is part of the operating system or is used exclusively by it.
FILE_ATTRIBUTE_TEMPORARY The file is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is available, because often the application deletes the temporary file shortly after the handle is closed. In that case, the system can entirely avoid writing the data. Otherwise, the data will be written after the handle is closed.
返回值: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.
f=fopen("1.dat","w");
SetFileAttributes("1.dat", FILE_ATTRIBUTE_HIDDEN);
系统是这个 FILE_ATTRIBUTE_SYSTEM
隐藏是这个 FILE_ATTRIBUTE_HIDDEN
这种问题你去看 msdn 帮助文档就行了。给你贴出来帮助
函数原型
BOOL SetFileAttributes(
LPCTSTR lpFileName,
DWORD dwFileAttributes
);
参数:
lpFileName [in] Pointer to a string that specifies 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 Naming a File.
Windows Me/98/95: This string must not exceed MAX_PATH characters.dwFileAttributes [in] File attributes to set for the file. This parameter can be one or more of the following values. However, all other values override FILE_ATTRIBUTE_NORMAL.
属性:
Attribute Meaning
FILE_ATTRIBUTE_ARCHIVE The file is an archive file. Applications use this attribute to mark files for backup or removal.
FILE_ATTRIBUTE_HIDDEN The file is hidden. It is not included in an ordinary directory listing.
FILE_ATTRIBUTE_NORMAL The file has no other attributes set. This attribute is valid only if used alone.
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED The file will not be indexed by the content indexing service.
FILE_ATTRIBUTE_OFFLINE The data of the file is not immediately available. This attribute indicates that the file data has been physically moved to offline storage. This attribute is used by Remote Storage, the hierarchical storage management software. Applications should not arbitrarily change this attribute.
FILE_ATTRIBUTE_READONLY The file is read-only. Applications can read the file but cannot write to it or delete it.
FILE_ATTRIBUTE_SYSTEM The file is part of the operating system or is used exclusively by it.
FILE_ATTRIBUTE_TEMPORARY The file is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is available, because often the application deletes the temporary file shortly after the handle is closed. In that case, the system can entirely avoid writing the data. Otherwise, the data will be written after the handle is closed.
返回值: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.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询