使用Python实现win32下IconOverlay开发

本文介绍如何在Windows环境下,利用Python实现文件和文件夹图标的覆盖(Icon Overlay)。通过理解Windows的Icon Overlay原理,学习相关接口和接口实现,以及参考TortoiseSVN的实现,读者将掌握创建自定义Icon Overlay的技术。文章包含概念解析、动手实践及源码参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目标:在现有Python客户端中实现文件夹和文件图标覆盖[Icon Overlay]

适用范围: win32 系统 , python2.6

构思:

第一阶段:学习Window Icon Overlay实现概念

直观了解

[转载]  How to overlay an icon over existing shell objects in 3 easy steps 

阐述原理

[转载Creating Icon Overlay Handlers

Icon overlays are small images placed at the lower-left corner of the icon that represents a Shell object. They are normally added to an object's icon to provide some extra information. For instance, a commonly used icon overlay is the small arrow that indicates that the icon represents a link, rather than the actual file or folder. In addition to the standard icon overlays that are provided by the system, you can request custom icon overlays for specified Shell objects by implementing and registering an icon overlay handler.

Note   The number of different icon overlay handlers that the system can support is limited by the amount of space available for icon overlays in the system image list. There are currently fifteen slots allotted for icon overlays, some of which are reserved by the system. For this reason, icon overlay handlers should be implemented only if there are no satisfactory alternatives.

[转载]  How to Implement Icon Overlay Handlers

Icon overlay handlers are in-process Component Object Model (COM) objects, implemented as DLLs. 

They export one interface in addition to IUnknownIShellIconOverlayIdentifier.

 This interface has three methods:

 IShellIconOverlayIdentifier::GetOverlayInfo

 IShellIconOverlayIdentifier::GetPriority

 IShellIconOverlayIdentifier::IsMemberOf


成功案例

[转载]The documentation for the TortoiseOverlays project explains how they use it and the problems they have encountered (username: guest, empty password), and the GPL'ed sourcecode is in the Subversion repository (same username/password as above)


第二阶段:动手练习

       [入门练习] 去 Microsoft CodePlex Open Source Community 下载 All-In-One Code Framework Sample Browser 客户端

         


下载源代码结构说明,根据Readme.txt可以学习到一些。

编外话:第一次做VS用了半天时间VS2008-VS2010的工作,成功编译dll,但build后不能运行的错误还没有解决。

                 这个解决方式使用笨方式下载VS2008后打开源代码工程没有问题。编译执行DLL也没问题。但要注意:

                HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers\目录下

                 注册键值不要超过15个,采用..SampleATLShellExtIconOverlayHandler命名尽量排在前面,超过15个后面的将不起作用。



      [TortoiseSVN] 学习开源TortoiseSVN对IconOverlay使用

      源代码下载地址 :https://tortoisesvn.googlecode.com/svn/trunk

     如果你对Microsoft Visual Studio 2010不熟悉可以Baidu一下

     [Microsoft Visual Studio C++ 2010 入门经典]

     [Beginning Visual C++ 2008] Ivor Horton著

      学习一下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值