程序化桌面图标放置

发布于 2024-07-25 08:41:17 字数 137 浏览 5 评论 0原文

我正在寻找一种以编程方式获取/设置桌面上的图标位置的方法。 显然有一些“状态”存储在某处。 有谁知道哪里吗?

我正在尝试在任何平台上进行概念验证,因此如果您知道如何在 gnome、KDE ​​或 macOS 中的 XP 上进行操作。

I am looking for a way to programmatically get/set the icon positions on the desktop.
Clearly there is some "state" stored somewhere. Does anybody know where?

I am trying to get a proof of concept going on ANY platform so if you know how to do it on XP in gnome, KDE or macOS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

司马昭之心 2024-08-01 08:41:17

从这里开始:http://msdn.microsoft.com/en -us/library/bb773177(VS.85).aspx

不幸的是,这是一个相当令人讨厌的 API,因为 shell 中的每个对象都由一个称为 PIDL 的东西来标识,PIDL 是由撒旦自己创建的,目的是迷惑任何试图避免的人访问冲突和内存泄漏。

Start here: http://msdn.microsoft.com/en-us/library/bb773177(VS.85).aspx

It's unfortunately quite a nasty API because every object in the shell is identified by a thing called a PIDL, which was created by Satan himself to confuse anyone trying to avoid access violations and memory leaks.

无敌元气妹 2024-08-01 08:41:17

普通文件和文件夹的位置存储在隐藏的 .DS_Store 文件中,该文件存在于任何目录
Mac OS X 上音量图标的位置似乎存储在 Finders .plist (~/Library/Preferences/com.apple.finder) 中。

Position of normal files and folders is stored in the hidden .DS_Store file, that exists for any directory
The position of volume icons on Mac OS X seems to be stored in the Finders .plist (~/Library/Preferences/com.apple.finder).

黯然#的苍凉 2024-08-01 08:41:17

对于遵循 freedesktop.org 规范的桌面(无论它们可能存在缺陷),相关文档似乎是 此处; 不过,它没有提及任何有关职位的信息。

For desktops following the freedesktop.org specifications (however flawed they may be), the relevant document seems to be here; it does not say anything about positions, though.

烧了回忆取暖 2024-08-01 08:41:17

这里的很多答案都说在 Windows 中做这种事情相当困难。 我怀疑这并非偶然。 如果您从未阅读过 Raymond Chen 的博客老新事物,我建议您阅读一下。 陈先生经常讨论以编程方式访问图标放置等内容时出现的陷阱和滥用。

编辑:以下是有关在 Windows 中允许编程访问的一些注释。

烦人者 可能并不意味着能够做到这一点(至少在 Windows 上),但这并不意味着它不能完成。 我只是要求你们本着善良而不是邪恶的精神来做这件事。

A lot of the answers here are saying that doing this sort of thing is pretty difficult to do in Windows. I suspect that this is not by accident. If you've never read Raymond Chen's blog The Old New Thing I suggest you do. Mr. Chen frequently discusses the pitfalls and abuse that occur with programmatic access to things such as the placement of icons.

Edit: Here are some commentaries about allow programmatic access in Windows.

Although you're probably not meant to be able to do this (at least on Windows), that doesn't mean that it can't be done. I just ask that you do this in the spirit of good and not evil.

梦里梦着梦中梦 2024-08-01 08:41:17

过去几年我曾多次尝试研究这个问题,
这看起来是一件微不足道的事情(这是针对 AmigaDos 工作台),
但是 Windows shell 的编程很丑陋;
事实上,在 Windows API 中编程任何东西都是丑陋的。 这是一个可怕的混乱。
准备好迎接一堆头发拉扯和心痛吧。

并不是要让您灰心丧气,但微软认为它什么时候到来才是最清楚的
到文件夹视图中的图标放置,我发现几乎没有办法
实现“永久”图标放置(即图标视图远非永久)。
MSDN 文档在这方面提供的帮助很少(至少没有示例)。
我研究的最后一件事是编写一个 shell 扩展来记录和恢复
图标位置(我不会将这些记录在注册表中,我只是将位置存储在文件夹的desktop.ini 文件中,但最好在用户的私人设置文件夹中创建一个文件)。

Code Project 有许多关于 shell 编程和扩展的文章。

http://www.codeproject.com/KB/shell/
http://www.codeproject.com/KB/shell/shlext.aspx

我最终用漂亮干净的纯 C++ 编写了自己的小 shell
这正是我在应用程序中想要的。

I've tried looking into this a couple of times the last couple of years,
it seems like such a trivial thing (It was for the AmigaDos workbench),
but programming for the Windows shell is ugly;
actually programming anything in the Windows API is ugly. Its a horrible mess.
Be prepared for a bunch of hair pulling and heart ache.

Not to discourage you, but MicroSoft thinks it knows best when it comes
to icon placement in folder views and I have found little in a way to
implement 'permanent' icon placement (I.e. Icon view is far from permanent).
The MSDN docs offer little help in this regard (at least no examples).
The last thing I looked into was writing a shell extension to record and restore
icon position (I wouldn't record these in the registry, I was just going to store positions in the folder's desktop.ini file, but it would probably be better to create a file in the user's private settings folder).

Code Project has a number of articles on shell programming and extensions.

http://www.codeproject.com/KB/shell/
http://www.codeproject.com/KB/shell/shlext.aspx

I ended up writing my own little shell in nice clean pure C++
that does exactly what I want in the context of my application.

神仙妹妹 2024-08-01 08:41:17

在 GNOME 中,Nautilus 将图标和其他内容的位置存储在 ~/.nautilus/metafiles 中。

那里的文件有难看的文件名,因为它们实际上是转义的 URI。 例如,我的桌面图标的元数据位于 ~/.nautilus/metafiles/file:%2F%2F%2Fhome%2Ffederico%2FDesktop.xml

但是,没有公共接口来访问或修改该数据。 您当然可以自行解析该文件并进行修改,但更改要等到下次重新启动 Nautilus 时才会生效。

In GNOME, Nautilus stores the position of icons and other stuff in ~/.nautilus/metafiles.

The files in there have ugly filenames, as they are really escaped URIs. For example, my metadata for my desktop icons lives in ~/.nautilus/metafiles/file:%2F%2F%2Fhome%2Ffederico%2FDesktop.xml

There is no public interface to access or modify that data, however. You can of course parse the file on your own and modify it, but the changes will not take effect until the next time you restart Nautilus.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文