创建图标标记 Handlers (续)

分手后的思念是犯贱 2022-06-02 01:21 224阅读 0赞

https://www.cnblogs.com/lantingji/p/5853790.html

1、新建一个ATL Project。

1022478-20160908170052316-1713579722.png

2、建议将 Project Property 中 Linker – General - “Register Output” 设为 no,C/C++ - “Code Generation” - “Runtime Library” 设为 /MTd。

1022478-20160908170106394-1317427357.png

1022478-20160908170110644-595317946.png

3、在 Solution Explorer 中右键 Add Class,选择 ATL Simple Object。并在弹出的对话框中为该 Class 命名。

1022478-20160908170124285-221931208.png

1022478-20160908170136519-685095860.png

4、添加完成后建议 Build 一下 Project,MIDL compiler 将根据 .idl 文件生成 IIDs and CLSIDs。

1022478-20160908170242613-1943825496.png

5、切换到新增 Class 的 .h 文件中,使其继承接口 IShellIconOverlayIdentifier。

1022478-20160908170256394-177897103.png

1022478-20160908170305973-2104139834.png

1022478-20160908170311254-1139053894.png

1022478-20160909143515254-2032471086.png

ContractedBlock.gif MyOverlay.h

6、根据 MSDN 实现该 Class。

1022478-20160908170620785-753300576.png

1022478-20160908170645910-890432900.png

1022478-20160908170652035-1856550351.png

1022478-20160908170818504-607745033.png

ContractedBlock.gif MyOverlay.cpp

7、在 .rgs 文件中添加注册表信息,确保各 GUID 与 .idl 文件中的一致。

复制代码

  1. 1 HKCR
  2. 2 {
  3. 3 NoRemove CLSID
  4. 4 {
  5. 5 ForceRemove {
  6. 29913677-1662-46C5-8645-16F84DA6F438} = s 'MyOverlay Class'
  7. 6 {
  8. 7 ForceRemove Programmable
  9. 8 InprocServer32 = s '%MODULE%'
  10. 9 {
  11. 10 val ThreadingModel = s 'Apartment'
  12. 11 }
  13. 12 TypeLib = s '{942F4DBB-4667-4767-A35B-52F32F623C63}'
  14. 13 Version = s '1.0'
  15. 14 }
  16. 15 }
  17. 16 }
  18. 17
  19. 18 HKLM
  20. 19 {
  21. 20 NoRemove SOFTWARE
  22. 21 {
  23. 22 NoRemove Microsoft
  24. 23 {
  25. 24 NoRemove Windows
  26. 25 {
  27. 26 NoRemove CurrentVersion
  28. 27 {
  29. 28 NoRemove Explorer
  30. 29 {
  31. 30 NoRemove ShellIconOverlayIdentifiers
  32. 31 {
  33. 32 ForceRemove ' MyOverlay' = s '{29913677-1662-46C5-8645-16F84DA6F438}'
  34. 33 {
  35. 34 }
  36. 35 }
  37. 36 }
  38. 37 }
  39. 38 }
  40. 39 }
  41. 40 }
  42. 41 }

复制代码

8、Build Project 后通过 cmd.exe 注册或解注册生成的 .dll 文件。重启 explorer.exe 后生效。

1022478-20160908171236504-1001365965.png

1022478-20160908171244613-361205677.png

1022478-20160908171247941-339748628.png

9、由于 slots 数量有限,检查在注册表中添加的子项是否在有效范围内(目前为前15个)。按下Win+R键,通过运行对话框打开regedit.exe,按HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers的顺序依次展开或直接Ctrl+F查找到MyOverlay项。可采用在.rgs文件中的子项名称前添加空格的方式将其位置提前。

1022478-20160918113959534-652571738.png

1022478-20160908171302598-587679768.png

10、查看效果如下图所示。

1022478-20160908172154910-644920164.png

参考网址: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

好文要顶 关注我 收藏该文 icon_weibo_24.png wechat.png

sample_face.gif

兰亭集
关注 - 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) 编辑 收藏

发表评论

表情:
评论列表 (有 0 条评论,224人围观)

还没有评论,来说两句吧...

相关阅读