在 Windows 资源管理器上下文菜单中订购
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7007852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Order in the Windows Explorer context menu
提问by ixSci
How can I change the order of the entries in the context menu?(e.g. for Directories) I need to know how Windows determines the order when showing that so I can control it. For example I want to place my custom action at the end of the context menu list
如何更改上下文菜单中条目的顺序?(例如对于目录)我需要知道 Windows 在显示时如何确定顺序,以便我可以控制它。例如,我想将自定义操作放在上下文菜单列表的末尾
Thank in advance!
预先感谢!
回答by Luke
My Google-fu led me to this:
我的 Google-fu 引导我这样做:
So the sorting is based on the following elements in decision order:
- Key priority (eg, txtfile, *, AFSO)
- Registry Enumeration order of shellex\contextmenuhandlers with a special case for static verbs always being first
- IContextMenu Implementation order
So if there is any contention for position, there is no consistent way for an extension to guarantee their relative position within the menu.
所以排序是基于以下元素的决策顺序:
- 密钥优先级(例如,txtfile、*、AFSO)
- shellex\contextmenuhandlers 的注册表枚举顺序,静态动词的特殊情况总是首先
- IContextMenu 实现顺序
因此,如果存在任何位置争用,则扩展没有一致的方式来保证它们在菜单中的相对位置。
Obviously you can't do anything about phase 1. Phase 3 only applies to the verbs implemented in your handler. That leaves phase 2. The only thing you can do is name your entry under ContextMenuHandlers such that it would be enumerated first, but nothing's stopping someone else from doing the same thing.
显然你不能对阶段 1 做任何事情。阶段 3 只适用于你的处理程序中实现的动词。剩下第 2 阶段。您唯一可以做的就是在 ContextMenuHandlers 下命名您的条目,以便它首先被枚举,但没有什么能阻止其他人做同样的事情。
回答by 244an
This is for Windows 7, maybe same for newer versions. It was inspired by the other answers, all is affecting the order.
这适用于 Windows 7,对于较新的版本可能相同。它受到其他答案的启发,都在影响订单。
I'm explaining entries for "*" (all files), but the same goes for special extensions.
我正在解释“*”(所有文件)的条目,但特殊扩展名也是如此。
I take no responsibility for any changes made in registry!
我对注册表中的任何更改不承担任何责任!
There are three sections in the context menu, as it says in How to Change the Order of Options in Context Menu(from answer by @Anonymouse)
上下文菜单中有三个部分,如如何更改上下文菜单中的选项顺序中所述(来自@Anonymouse 的回答)
They call them:
他们称他们为:
2 - Default menu position (at the top).
1 - Send to, copy to folder and move to folder menu part (in the middle).
0 - Rename menu part (at the bottom).
Within these sections the position is decided by the rules in answer by @Luke
The easiest way to change the order within the "section" is to change the name of the registry key under HKCR-*-shell
or HKCR-*-shellex
. All under subkey shell
will be before them under shellex
. Keys that have the CLSID
as the key name will be as last entry since they are last in the used order.
在这些部分中,位置由@Luke 回答的规则决定。
更改“部分”内顺序的最简单方法是更改HKCR-*-shell
或下的注册表项名称HKCR-*-shellex
。所有在 subkey 下的shell
都将在它们之前shellex
。具有CLSID
作为键名的键将作为最后一个条目,因为它们在使用的顺序中排在最后。
As an example, I was following a sample from MSDN to build a Context Menu Handler. That is using the CLSID
as the name for the key under shellex
, and a "friendly name" as default value. It was placed at the bottom of "section" 2 (top section). I changed the key name to something like Asample
and changed the default value to be the CLSID
instead. Now it was directly after entries under shell
.
例如,我按照MSDN 中的示例构建了一个 Context Menu Handler。即使用CLSID
用作 下键的名称shellex
,并使用“友好名称”作为默认值。它被放置在“部分”2(顶部部分)的底部。我将密钥名称更改为类似的名称Asample
并将默认值更改为CLSID
。现在它直接在shell
.
There are some more ways of changing the order.
还有一些改变顺序的方法。
For keys under shell
you can add the value Position
with string data Top
or Bottom
. Not possible to decide in what "section".
对于下面的键,shell
您可以Position
使用字符串数据Top
或Bottom
. 无法决定在哪个“部分”。
For keys under shellex
the value Position
has no effect. Instead it's possible to decide in what "section" the entry will be using flags
, described in the linkabove.
对于shellex
值下的键Position
没有影响。相反,可以决定条目将在哪个“部分”中使用flags
,如上面的链接所述。
- Use the
CLSID
for the shellext you want to move. It's like{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
. Get it either from the key name or the default value, it depends on how the entry is done.- Find the entry under HKCR-CLSID, the key has the name of the
CLSID
.- Add a value with name
flags
and dataDWORD
with the "section" number described above under the foundCLSID
.
CLSID
对要移动的 shellext使用。就像{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
. 从键名或默认值获取它,这取决于条目是如何完成的。- 找到 HKCR-CLSID 下的条目,键的名称为
CLSID
.- 添加具有名称的值
flags
和数据DWORD
与找到的下上述“部分”号码CLSID
。
回答by Bin TAN - Victor
This Q&Ashows a simple way to CREATE (not move) an item within the context menu. I managed to duplicate an existing item. Then I moved my item to a higher and more accessible position within the context menu, by renaming the key to start with something "aMyItem" or "0MyItem".
此问答展示了一种在上下文菜单中创建(而不是移动)项目的简单方法。我设法复制了一个现有项目。然后,通过将键重命名为以“aMyItem”或“0MyItem”开头,我将我的项目移动到上下文菜单中更高且更易于访问的位置。
回答by Anonymouse
This did it for me... Steps 4 through 7 - setting the "flags" http://techoqueries.blogspot.de/2012/08/how-to-change-order-of-options-in.html
这为我做到了......第 4 步到第 7 步 - 设置“标志” http://techoqueries.blogspot.de/2012/08/how-to-change-order-of-options-in.html