[python-win32] Creating python com objects

Roger Upole rwupole at msn.com
Thu Apr 24 12:52:30 CEST 2008


Alex Denham wrote:

class PyIDropTarget:
    _public_methods_ = ['DragEnter', 'DragOver', 'DragLeave', 'Drop']
    _reg_progid_ = "Python.PyIDropTarget"
    _reg_clsid_ = '{00000122-0000-0000-C000-000000000046}'
    def DragEnter(self, args=None):
        print 'DragEnter: ', args
    def DragOver(self, args=None):
        print 'DragOver: ', args
    def DragLeave(self, args=None):
        print 'DragLeave: ', args
    def Drop(self, args=None):
        print 'Drop: ', args

Your class also needs to specify the IID of the interface it
implements, eg
    _com_interfaces_=[pythoncom.IID_IDropTarget]

Also, the _reg_clsid_ should be a unique GUID that you
generate yourself to identify your own implementation of
IDropTarget, rather than the system GUID for IDropTarget.

        Roger




More information about the python-win32 mailing list