Registering Shell Extension Handlers
最近在做Windows shell extension 的开发工作,对shell extension handler的注册机制有点疑问,以下摘自MSDN:http://msdn.microsoft.com/en-us/library/windows/desktop/cc144067(v=vs.85).aspx
Registering Shell Extension Handlers
A Shell extension handler object must be registered before the Shell can use it. This section is a general discussion of how to register a Shell extension handler.
Any time you create or change a Shell extension handler, it is important to notify the system that you have made a change with SHChangeNotify, specifying the SHCNE_ASSOCCHANGED event. If you do not call SHChangeNotify, the change might not be recognized until the system is rebooted.
As with all COM objects, you must create a GUID for the handler using a tool such as UUIDGEN.exe. Create a key under HKEY_CLASSES_ROOT\CLSID whose name is the string form of the GUID. Because Shell extension handlers are in-process servers, you must create an InProcServer32 key under the GUID key with the default value set to the path of the handler's DLL. Use the Apartment threading model.
Any time the Shell takes an action that can involve a Shell extension handler, it checks the appropriate registry key. The key under which an extension handler is registered thus controls when it will be called. For instance, it is a common practice to have a shortcut menu handler called when the Shell displays a shortcut menu for a member of a file type. In this case, the handler must be registered under the file type's ProgID key.
Handler Names
To enable a Shell extension handler, create a subkey with the handler subkey name (see below) under the ShellEx subkey of either the ProgID (for file types) or the Shell object type name (for Predefined Shell Objects).
For example, if you wanted to register a shortcut menu extension handler for MyProgram.1, you would begin by creating the following subkey:
HKEY_CLASSES_ROOT
MyProgram.1
ShellEx
ContextMenuHandlers
For the following handlers, create a subkey underneath the "Handler Subkey name" key whose name is the string version of the CLSID of the Shell extension. Multiple extensions can be registered under the handler subkey name key by creating multiple subkeys.
| Handler | Interface | Handler Subkey Name |
|---|---|---|
| Shortcut menu handler | IContextMenu | ContextMenuHandlers |
| Copyhook handler | ICopyHook | CopyHookHandlers |
| Drag-and-drop handler | IContextMenu | DragDropHandlers |
| Property sheet handler | IShellPropSheetExt | PropertySheetHandlers |
| Column provider handler (deprecated in Windows Vista) | IColumnProvider | ColumnHandlers |
For the following handlers, the default value of the "Handler Subkey Name" key is the string version of the CLSID of the Shell extension. Only one extension can be registered for these handlers.
| Handler | Interface | Handler Subkey Name |
|---|---|---|
| Data handler | IDataObject | DataHandler |
| Drop handler | IDropTarget | DropHandler |
| Icon handler | IExtractIconA/W | IconHandler |
| Image handler | IExtractImage | {BB2E617C-0920-11d1-9A0B-00C04FC2D6C1} |
| Thumbnail image handler | IThumbnailProvider | {E357FCCD-A995-4576-B01F-234630154E96} |
| Infotip handler | IQueryInfo | {00021500-0000-0000-C000-000000000046} |
| Shell link (ANSI ) | IShellLinkA | {000214EE-0000-0000-C000-000000000046} |
| Shell link (UNICODE) | IShellLinkW | {000214F9-0000-0000-C000-000000000046} |
| Structured storage | IStorage | {0000000B-0000-0000-C000-000000000046} |
| Metadata | IPropertyStore | PropertyHandler |
| Metadata | IPropertySetStorage (deprecated in Windows Vista) | PropertyHandler |
| Pin to Start Menu | IStartMenuPinnedList | {a2a9545d-a0c2-42b4-9708-a0b2badd77c8} |
| Pin to Taskbar | {90AA3A4E-1CBA-4233-B8BB-535773D48449} |
The subkeys specified to add Pin to Start Menu and Pin to Taskbar to an item's shortcut menu are only required for file types that include the IsShortCut entry.
Support for column provider handlers was removed in Windows Vista. Also, as of Windows Vista,IPropertySetStorage has been deprecated in favor of IPropertyStore.
While IExtractImage remains supported, IThumbnailProvider is preferred for Windows Vista and later.
Predefined Shell Objects
The Shell defines additional objects under HKEY_CLASSES_ROOT which can be extended in the same way as file types. For example, to add a property sheet handler for all files, you can register under thePropertySheetHandlers key.
HKEY_CLASSES_ROOT
*
shellex
PropertySheetHandlers
The following table gives the various subkeys of HKEY_CLASSES_ROOT under which extension handlers can be registered. Note that many extension handlers cannot be registered under all of the listed subkeys. For further details, see the specific handler's documentation.
| Subkey | Description | Possible Handlers | Version |
|---|---|---|---|
| * | All files | Shortcut Menu, Property Sheet, Verbs (see below) | All |
| AllFileSystemObjects | All files and file folders | Shortcut Menu, Property Sheet, Verbs | 4.71 |
| Folder | All folders | Shortcut Menu, Property Sheet, Verbs | All |
| Directory | File folders | Shortcut Menu, Property Sheet, Verbs | All |
| Directory\Background | File folder background | Shortcut Menu only | 4.71 |
| Drive | All drives in MyComputer, such as "C:\" | Shortcut Menu, Property Sheet, Verbs | All |
| Network | Entire network (under My Network Places) | Shortcut Menu, Property Sheet, Verbs | All |
| Network\Type\# | All objects of type # (see below) | Shortcut menu, Property Sheet, Verbs | 4.71 |
| NetShare | All network shares | Shortcut menu, Property Sheet, Verbs | 4.71 |
| NetServer | All network servers | Shortcut menu, Property Sheet, Verbs | 4.71 |
| network_provider_name | All objects provided by network provider "network_provider_name" | Shortcut menu, Property Sheet, Verbs | All |
| Printers | All printers | Shortcut Menu, Property Sheet | All |
| AudioCD | Audio CD in CD drive | Verbs only | All |
| DVD | DVD drive (Windows 2000) | Shortcut Menu, Property Sheet, Verbs | 4.71 |
Notes:
- The file folder background shortcut menu is accessed by right-clicking within a file folder, but not over any of the folder's contents.
- "Verbs" are special commands registered under HKEY_CLASSES_ROOT\Subkey\Shell\Verb .
- For Network\Type\# , "#" is a network provider type code in decimal. The network provider type code is the high word of a network type. The list of network types is given in the Winnetwk.h header file (WNNC_NET_* values). For example, WNNC_NET_SHIVA is 0x00330000, so the corresponding type key would be HKEY_CLASSES_ROOT\Network\Type\51 .
- "network_provider_name" is a network provider name as specified by WNetGetProviderName, with the spaces converted into underscores. For example, if the Microsoft Networking network provider is installed, its provider name is "Microsoft Windows Network", and the correspondingnetwork_provider_name is Microsoft_Windows_Network.
Example of an Extension Handler Registration
To enable a particular handler, create a subkey under the extension handler type key with the name of the handler. The Shell does not use the handler's name, but it must be different from all other names under that type subkey. Set the default value of the name subkey to the string form of the handler's GUID.
The following example illustrates registry entries that enable shortcut menu and property sheet extension handlers, using an example .myp file type:
HKEY_CLASSES_ROOT
.myp
(Default) = MyProgram.1
CLSID
{00000000-1111-2222-3333-444444444444}
InProcServer32
(Default) = C:\MyDir\MyCommand.dll
ThreadingModel = Apartment
{11111111-2222-3333-4444-555555555555}
InProcServer32
(Default) = C:\MyDir\MyPropSheet.dll
ThreadingModel = Apartment
MyProgram.1
(Default) = MyProgram Application
Shellex
ContextMenuHandler
MyCommand
(Default) = {00000000-1111-2222-3333-444444444444}
PropertySheetHandlers
MyPropSheet
(Default) = {11111111-2222-3333-4444-555555555555}
The registration procedure discussed in this section must be followed for all Windows systems.
Registering Shell Extension Handlers的更多相关文章
- Writing a Windows Shell Extension(marco cantu的博客)
Writing a Windows Shell Extension This is a technical article covering the content of my last week s ...
- Windows Shell Extension 系列文章
Windows Shell Extension 系列文章 http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-C ...
- Link Shell Extension
Link Shell Extension http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html
- GNOME Shell Extension常用扩展
这篇博文的,主要目的是为了方便我和大家安装GNOME扩展.我将我安装过的所有扩展列在此处. 常用扩展 Clipboard Indicator https://extensions.gnome.org/ ...
- Creating Icon Overlay Handlers / 创建图标标记 Handlers (翻译自MSDN) / VC++, Windows, DLL, ATL, COM
创建图标标记 Handlers Creating Icon Overlay Handlers 图标标记是放在代表着某个 Shell 对象的图标之左下角的小图像.它们通常被加在一个对象的图标的身上来提供 ...
- [翻译].NET Shell Extensions - Shell Context Menus---.net 外壳扩展-右键菜单
我自己的前言说明: 本文原作者为 Dave Kerr,原文链接为.NET Shell Extensions - Shell Context Menus:,我是在为了完成最新需求的时候查询资料的时 ...
- Delphi编写Shell扩展
用delphi创建一个外壳扩展(Shell Extension)程序的基本步骤如下: (1) 创建一个 ActiveX Library 工程,命名为“CloudUpload“(2) 创建一个新的自动化 ...
- Akka源码分析-Extension
一个设计优秀的工具或框架,应该都有一个易用.强大的插件或扩展体系,akka也不例外. akka的扩展方法非常简单,因为只涉及到两个组件:Extension. ExtensionId.其中Extensi ...
- 如何使用 GNOME Shell 扩展
如何使用 GNOME Shell 扩展 作者: Abhishek Prakash 译者: LCTT MjSeven | 2018-03-15 10:53 评论: 1 简介:这是一份详细指南,我将会 ...
随机推荐
- Android之如何混淆代码和相关配置
昨天,客户想看一下目前项目开发到什么程度了,于是需要将项目签名打包成apk,结果打包的时候出错了,吃惊,什么情况.等成功打包以后,安装起来发现部分功能又报错了,囧,所幸最后还是解决了.在这里记录一下遇 ...
- shell脚本学习之if..else用法
一 简介 1 字符串判断 str1 = str2 当两个串有相同内容.长度时为真 str1 != str2 当串str1和str2不等时为真 -n str1 当串的长度大于0时为真(串非空) - ...
- OC - 19.GCD
简介 GCD(Grand Center Dispatch)是Apple为多核的并行运算提出的解决方案,纯C语言 更加适配多核处理器,且自动管理线程的生命周期,使用起来较为方便 GCD通过任务和队列实现 ...
- 基于nodejs的消息中心
参考:http://t42dw.iteye.com/blog/1767013
- 自己制作精美的App Store 软件截屏
当用户搜索到App的时候,一般都会先看截图,如果截图效果不好,可能用户就不会下载. 不想自己辛苦写的认为还不错的软件,因为截图的原因,而降低了很多下载量吧. 轻轻松松做出这样高大上的截屏效果来. Sc ...
- 『重构--改善既有代码的设计』读书笔记----Remove Middle Man
如果你发现某个类做了过多的简单委托动作,你就可以考虑是否可以让客户直接去调用受托类.在Hide Delegate中,我们介绍了封装受托对象的好处,但好处归好处也存在代价,就是当你每次需要在受托对象中增 ...
- 浅谈Chrome V8引擎中的垃圾回收机制
垃圾回收器 JavaScript的垃圾回收器 JavaScript使用垃圾回收机制来自动管理内存.垃圾回收是一把双刃剑,其好处是可以大幅简化程序的内存管理代码,降低程序员的负担,减少因 长时间运转而带 ...
- 微博输入相关js 代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 用Raphael在网页中画圆环进度条
原文 :http://boytnt.blog.51cto.com/966121/1074215 条状的进度条我们见得太多了,实现起来比较简单,它总是长方形的,在方形的区域里摆 放就不太好看了.随着cs ...
- Ubuntu使用Xming和Putty
运行个复杂的,比如 gnome-session,这个是 GNOME 的启动命令,如果想打开 KDE 就是 startkde root@carlo-cloud:~# xlogoThe program ' ...