创建图标标记 Handlers (续)
https://www.cnblogs.com/lantingji/p/5853790.html
1、新建一个ATL Project。
2、建议将 Project Property 中 Linker – General - “Register Output” 设为 no,C/C++ - “Code Generation” - “Runtime Library” 设为 /MTd。
3、在 Solution Explorer 中右键 Add Class,选择 ATL Simple Object。并在弹出的对话框中为该 Class 命名。
4、添加完成后建议 Build 一下 Project,MIDL compiler 将根据 .idl 文件生成 IIDs and CLSIDs。
5、切换到新增 Class 的 .h 文件中,使其继承接口 IShellIconOverlayIdentifier。
MyOverlay.h
6、根据 MSDN 实现该 Class。
MyOverlay.cpp
7、在 .rgs 文件中添加注册表信息,确保各 GUID 与 .idl 文件中的一致。
1 HKCR
2 {
3 NoRemove CLSID
4 {
5 ForceRemove {
29913677-1662-46C5-8645-16F84DA6F438} = s 'MyOverlay Class'
6 {
7 ForceRemove Programmable
8 InprocServer32 = s '%MODULE%'
9 {
10 val ThreadingModel = s 'Apartment'
11 }
12 TypeLib = s '{942F4DBB-4667-4767-A35B-52F32F623C63}'
13 Version = s '1.0'
14 }
15 }
16 }
17
18 HKLM
19 {
20 NoRemove SOFTWARE
21 {
22 NoRemove Microsoft
23 {
24 NoRemove Windows
25 {
26 NoRemove CurrentVersion
27 {
28 NoRemove Explorer
29 {
30 NoRemove ShellIconOverlayIdentifiers
31 {
32 ForceRemove ' MyOverlay' = s '{29913677-1662-46C5-8645-16F84DA6F438}'
33 {
34 }
35 }
36 }
37 }
38 }
39 }
40 }
41 }
8、Build Project 后通过 cmd.exe 注册或解注册生成的 .dll 文件。重启 explorer.exe 后生效。
9、由于 slots 数量有限,检查在注册表中添加的子项是否在有效范围内(目前为前15个)。按下Win+R键,通过运行对话框打开regedit.exe,按HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers的顺序依次展开或直接Ctrl+F查找到MyOverlay项。可采用在.rgs文件中的子项名称前添加空格的方式将其位置提前。
10、查看效果如下图所示。
参考网址:http://www.codeproject.com/Articles/7484/How-to-overlay-an-icon-over-existing-shell-objects
—————————————————————————————————————
本文为本人原创,如需转载请注明出处。
http://www.cnblogs.com/lantingji/p/5853790.html
分类: Windows 编程
标签: VC++, Windows, DLL, ATL, COM
好文要顶 关注我 收藏该文
兰亭集
关注 - 0
粉丝 - 0
+加关注
0
0
« 上一篇: Creating Icon Overlay Handlers / 创建图标标记 Handlers (翻译自MSDN) / VC++, Windows, DLL, ATL, COM
» 下一篇: Creating Context Menu / 创建上下文菜单项 / VC++, Windows, DLL, ATL, COM
posted on 2016-09-08 17:23 兰亭集 阅读(174) 评论(0) 编辑 收藏
还没有评论,来说两句吧...