Esempio n. 1
0
    def GetUIObjectOf(self, hwndOwner, pidls, iid, inout):
        assert len(pidls)==1, "oops - arent expecting more than one!"
        assert len(pidls[0])==1, "assuming relative pidls!"
        item = pidl_to_item(pidls[0])
        if iid == shell.IID_IContextMenu:
            ws = wrap(self)
            dcm = (hwndOwner, None, self.pidl, ws, pidls)
            return shell.SHCreateDefaultContextMenu(dcm, iid)
        elif iid == shell.IID_IExtractIconW:
            dxi = shell.SHCreateDefaultExtractIcon()
            # dxi is IDefaultExtractIconInit
            if item['is_folder']:
                dxi.SetNormalIcon("shell32.dll", 4)
            else:
                dxi.SetNormalIcon("shell32.dll", 1)
            # just return the dxi - let Python QI for IID_IExtractIconW
            return dxi

        elif iid == pythoncom.IID_IDataObject:
            return shell.SHCreateDataObject(self.pidl, pidls, None, iid);

        elif iid == shell.IID_IQueryAssociations:
            elts = []
            if item['is_folder']:
                elts.append((shellcon.ASSOCCLASS_FOLDER, None, None))
            elts.append((shellcon.ASSOCCLASS_PROGID_STR, None, ContextMenu._context_menu_type_))
            return shell.AssocCreateForClasses(elts, iid)

        raise COMException(hresult=winerror.E_NOINTERFACE)
Esempio n. 2
0
 def CreateViewObject(self, hwnd, iid):
     if iid == shell.IID_IShellView:
         com_folder = wrap(self)
         return shell.SHCreateShellFolderView(com_folder)
     elif iid == shell.IID_ICategoryProvider:
         return wrap(ViewCategoryProvider(self))
     elif iid == shell.IID_IContextMenu:
         ws = wrap(self)
         dcm = (hwnd, None, self.pidl, ws, None)
         return shell.SHCreateDefaultContextMenu(dcm, iid)
     elif iid == shell.IID_IExplorerCommandProvider:
         return wrap(ExplorerCommandProvider())
     else:
         raise COMException(hresult=winerror.E_NOINTERFACE)