我正在寻找一种方法来隐藏桌面上的特定图标。我通常在桌面上有很多图标(这使得找到一个文件非常麻烦),所以我想写一个小工具,在我输入时“过滤”它们。我不想“移动”或删除它们,只是隐藏(或加深)它们。我知道如何一次切换显示所有图标的隐藏状态,但不是基于每个图标。有任何想法吗?是否可以用C#隐藏特定的桌面图标?
回答
我试着以某种方式导航到桌面的ListView
控件(使用Win32 API)。然后,我要在要隐藏的项目上绘制一些半透明的矩形(可以使用宏/消息ListItem_GetItemRect
查询项目的矩形),从列表控件中临时删除项目,将项目的状态设置为CUT
(淡出),或者我会尝试操作列表视图的图像列表添加一个透明的图像,并将项目的图像设置为此。
但我不知道这种方法是否可行......而且我不确定我是否会在C#中尝试这样做(我宁愿使用C++)。
我真的很喜欢这个矩形的想法!我也会尝试这个。我想我会留在.NET中,我的Win32 C++经验几乎为零。 – crono 2010-02-20 16:05:15
@crono,我认为最好的选择是添加一个对COM库“Microsoft Shell Control And Automation”的引用,并使用Shell32.Shell对象。然后枚举快捷方式并设置快捷方式的文件属性(FileAttributes.Hidden)。
查看这些链接了解更多信息。
看到这个简单的例子,是不完整的,仅仅是一个草案。
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Shell32; //"Microsoft Shell Control And Automation"
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Shell32.Shell oShell;
Shell32.Folder oFldr;
oShell = new Shell32.Shell();
oFldr = oShell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDESKTOP);//point to the desktop
foreach (Shell32.FolderItem oFItm in oFldr.Items()) //get the shotrcuts
{
if (oFItm.IsLink)
{
Console.WriteLine("{0} {1} ", oFItm.Name, oFItm.Path);
bool isArchive = ((File.GetAttributes(oFItm.Path) & FileAttributes.Archive) == FileAttributes.Archive);
//bool isHidden = ((File.GetAttributes(oFItm.Path) & FileAttributes.Hidden) == FileAttributes.Hidden);
if (isArchive) //Warning, here you must define the condition for hide the shortcut. in this case only check if has set the Archive atribute.
{
//Now you can set FileAttributes.Hidden atribute
//File.SetAttributes(oFItm.Path, File.GetAttributes(oFItm.Path) | FileAttributes.Hidden);
}
}
else
{
Console.WriteLine("{0} {1} ", oFItm.Name, oFItm.Path);
}
}
Console.ReadKey();
}
}
}
这是一个好主意,但是我认为只有在将“显示隐藏文件”设置为“false”的情况下才能正常工作,而我大部分时间都是这样做的。也许我可以改变它“在飞行中”...我会看看。谢谢 :) – crono 2010-02-20 15:59:24
- 1. 是否可以隐藏特定的Google地图控件
- 2. 是否可以隐藏用户的特定应用程序?
- 3. 是否可以隐藏某个特定用户组的内容?
- 4. 隐藏Windows 8桌面图标
- 5. 如何通过使用c双击桌面来隐藏桌面图标#
- 6. 隐藏视图只是在桌面上
- 7. 隐藏桌面视图中特定单元格上的按钮
- 8. 是否可以隐藏子页面上的标题?
- 9. 是否可以在WPF DataGrid中隐藏特定的ColumnHeader?
- 10. 是否可以隐藏标准头部的一部分(C)?
- 11. 如何以编程方式隐藏桌面图标?
- 12. 在桌面上隐藏备用图像
- 13. Emacs:是否可以在桌面+中为特定桌面设置特定的缩进设置?
- 14. 隐藏以前的HTML桌面通知
- 15. 是否可以用动画隐藏UIToolbar?
- 16. 是否有可能以编程方式隐藏停靠图标
- 17. 是否可以在主屏幕上隐藏APP图标(Cordova - AngularApp)
- 18. 是否可以隐藏或操纵jqGrid“排序”图标?
- 19. 用于隐藏桌面图标的批处理脚本
- 20. 是否可以使用javascript隐藏PDF文档中的页面?
- 21. 有条件隐藏桌面屏幕的特定窗口
- 22. 通过命令行隐藏特定的桌面项目
- 23. 我可以为特定用户隐藏功能区上的图标吗?
- 24. 我可以隐藏特定页面的实际URL吗?
- 25. 隐藏或显示桌面视图
- 26. 在PyCharm中,是否可以禁用隐藏样式标签?
- 27. 是否可以使用命令退出C#代码隐藏块?
- 28. 用CSS隐藏div的特定页面
- 29. 是否可以“隐藏”语言扩展?
- 30. 是否可以隐藏AJAX API?
如果你把这个应用程序,将其发送给我吧:) – anthares 2010-02-19 01:01:01
当然 - 没问题,我会打开源它反正:-) – crono 2010-02-19 01:04:10