【问题标题】:Hiding the folder from the windows explorer从 Windows 资源管理器中隐藏文件夹
【发布时间】:2013-04-23 11:24:53
【问题描述】:

我希望从资源管理器中隐藏该文件夹。 当有人取消选中在文件夹中显示隐藏文件选项时,它应该不可见。

是否有任何 Shell API 来实现这一点,或者我如何在 MFC 或 win api 或 C++ 等中实现?有什么想法和建议吗?

【问题讨论】:

  • 索尼 Rootkit 成功了,回到过去 :)。

标签: mfc windows-shell


【解决方案1】:

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

【讨论】:

  • 我试过同样的事情 BOOL createFolder12 = CreateDirectory(temp,NULL); SetFileAttributes(temp,FILE_ATTRIBUTE_HIDDEN);当用户点击windows的在文件夹中显示隐藏文件和文件夹选项时,这将再次可见
  • 您的问题是您不希望在未选中“显示隐藏文件”时显示它。您的意思是您不希望它在检查时可见?
【解决方案2】:

不,不可能使用已记录或未记录的 Shell API。

【讨论】:

  • 那么如何实现这一点。
  • 从内核模式挂钩是最好的解决方案。
  • 不好意思说Hooking from kernel mode是为它写文件系统驱动。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-04
  • 1970-01-01
相关资源
最近更新 更多