【发布时间】:2013-04-23 11:24:53
【问题描述】:
我希望从资源管理器中隐藏该文件夹。 当有人取消选中在文件夹中显示隐藏文件选项时,它应该不可见。
是否有任何 Shell API 来实现这一点,或者我如何在 MFC 或 win api 或 C++ 等中实现?有什么想法和建议吗?
【问题讨论】:
-
索尼 Rootkit 成功了,回到过去 :)。
标签: mfc windows-shell
我希望从资源管理器中隐藏该文件夹。 当有人取消选中在文件夹中显示隐藏文件选项时,它应该不可见。
是否有任何 Shell API 来实现这一点,或者我如何在 MFC 或 win api 或 C++ 等中实现?有什么想法和建议吗?
【问题讨论】:
标签: mfc windows-shell
将SetFileAttributes 与标志FILE_ATTRIBUTE_HIDDEN 一起使用。为确保您不会意外清除其他属性,您需要先使用GetFileAttributes 读取目录属性。
例如:
void hidePath( const std::wstring& path )
{
const DWORD attributes = GetFileAttributes( path.c_str() );
SetFileAttributes( path.c_str(), attributes | FILE_ATTRIBUTE_HIDDEN );
}
另见:How to hide/un-hide a file without erasing other attributes in C++ on Windows
【讨论】:
不,不可能使用已记录或未记录的 Shell API。
【讨论】: