[python-win32] Calling ShellIconOverlayHandlers does not work

Lohse, Thomas Thomas.Lohse at tracetronic.de
Wed Nov 12 13:46:16 CET 2008


Hello,

could anyone provide some assistance in using ShellIconOverlay-Handlers
with pythoncom. I implement a kind of file explorer and would like to
call the ShellIconOverlay-Handlers (registered by TortoiseSVN) of the
windows explorer to visualize SVN-states. (I'm NOT about to implement my
own handler).

I can successfully CoCreateInstance these handlers and receive an
implementation of IShellIconOverlayIdentifier interface.
GetOverlayInfo() and GetPriority() both work fine on the interface, but
IsMemberOf(path, attributes) always returns None instead of S_OK,
S_FALSE, E_FAIL or an exception. This is the case whether the passed
path exists or not and is independent of the passed attributes.

Why does IShellIconOverlayIdentifier::IsMemberOf() not work? Any advice
or hint would be very appreciated.


Yours sincerely,
Thomas


My approach to using ShellIconOverlay handlers:

import sys
import pythoncom
import win32api, win32con

from win32com.shell import shell
from winerror import S_OK, S_FALSE, E_FAIL


def CallIconOverlayHandler():
    path = sys.argv[1] if len(sys.argv) > 1 else u"C:\\foo"
    
    # Query CLSID for 1st registered IconOverlayHandler
    # (there should be handler "Offline Files" at least, since included
in Win)
    regKey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE,
 
ur"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayId
entifiers")
    name = win32api.RegEnumKey(regKey, 0)
    clsId = win32api.RegQueryValue(regKey, name)
    win32api.RegCloseKey(regKey)
    
    print u"Using %s: %s" % (name, clsId)
    ovHdl = pythoncom.CoCreateInstance(clsId, None,
                                       pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellIconOverlayIdentifier)

    #Works fine
    print u"GetOverlayInfo():", ovHdl.GetOverlayInfo()
    print u"GetPriority():", ovHdl.GetPriority()

    #Problem: IsMemberOf returns always None
    print u"IsMemberOf(\"%s\", 0):" % path, ovHdl.IsMemberOf(path, 0)
    
    print u"Done."

if __name__ == "__main__":
    CallIconOverlayHandler()


More information about the python-win32 mailing list