Andrea Gavana wrote:
> Yes, thank you, it helps a lot... although I still have some doubts.
> These are my modifications of the class Roger posted:
> 
> class SIOI(object):
>     _reg_clsid_='{02844251-42C2-44CA-B43D-424FCE4F4660}'
>     _reg_progid_='K-SVR.IShellIconOverlayIdentifier'
>     _reg_desc_='Python implementation of IShellIconOverlayIdentifier'
>     _public_methods_ = ['GetOverlayInfo','GetPriority','IsMemberOf']
>     _com_interfaces_=[shell.IID_IShellIconOverlayIdentifier,
> pythoncom.IID_IDispatch]
>     __name__ = "SIOI"
> 
>     def __init__(self, fileNames):
>         self.fileNames = fileNames
> 
>     def AddFile(self, fileName):
>         if fileName not in self.fileNames:
>             self.fileNames.append(fileName)
> 
>     def RemoveFile(self, fileName):
>         if fileName in self.fileNames:
>             self.fileNames.remove(fileName)
> 
>     def GetOverlayInfo(self):
>         return (r'icons/KSVROverlay.ico', 0, shellcon.ISIOI_ICONFILE)
> 
>     def GetPriority(self):
>         return 50
> 
>     def IsMemberOf(self, fname, attributes):
>         if fname in self.fileNames:
>             return winerror.S_OK
>         return winerror.E_FAIL

Hmmm... Let's see how to explain this. Basically, this class
isn't one you instantiate within your own program as you've
done here. The instantiation is done by the underlying shell
integration mechanism. Think of it as a Windows Service,
running permanently. You don't start it with your app; it's
either running or it's not, regardless of what apps are running.

If you want it to adjust its overlays according to some changing
data characteristics, you're going to have to establish some kind
of mechanism by which the COM server which the class represents
can request the latest list of filenames from some other piece of
running code (or from a file or whatever).

That more-or-less also explains the error you reported in your
later email: the underlying mechanism expects an unadulterated
__init__, not one which you've altered to pass in your filenames.

Sorry if this isn't very clear; I did warn that this was not the easiest
part of Windows programming to get into. What it means is that 
your app comes in two pieces:

1) This Namespace Extension which determines -- somehow -- when
an icon requires an overlay and responds appropriately to requests
from the shell. You register it on its own and leave it alone.

2) The main app, doing whatever it's doing, possibly cooperating with
the Icon Overlay extension, for example by writing a list of filenames to 
a file from time to time.

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to