怎样用c++修改文件属性?

我如果要把d:\a.txt改成系统隐藏怎么办?是用SetFileAttributes吗?介绍一下吧,谢谢我想要系统属性+隐藏属性怎么弄啊... 我如果要把d:\a.txt 改成系统隐藏
怎么办?
是用SetFileAttributes 吗?介绍一下吧,谢谢
我想要 系统属性+隐藏属性怎么弄啊
展开
 我来答
百度网友a3151a3c8
推荐于2016-10-20 · TA获得超过419个赞
知道小有建树答主
回答量:98
采纳率:0%
帮助的人:113万
展开全部
用的时候

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.
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式