Python pythoncom 模块,IID_IDataObject() 实例源码

我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用pythoncom.IID_IDataObject()

项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
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)

    #  Retrieves the display name for the specified file object or subfolder.
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testIsCurrentClipboard(self):
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        self.failUnless(pythoncom.OleIsCurrentClipboard(do))
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testComToWin32(self):
        # Set the data via our DataObject
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        # Then get it back via the standard win32 clipboard functions.
        win32clipboard.OpenClipboard()
        got = win32clipboard.GetClipboardData(win32con.CF_TEXT)
        # CF_TEXT gives bytes on py3k - use str2bytes() to ensure that's true.
        expected = str2bytes("Hello from Python")
        self.assertEqual(got, expected)
        # Now check unicode
        got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
        self.assertEqual(got, u"Hello from Python")
        win32clipboard.CloseClipboard()
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testDataObjectFlush(self):
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        self.assertEqual(num_do_objects, 1)

        do = None # clear my ref!
        pythoncom.OleFlushClipboard()
        self.assertEqual(num_do_objects, 0)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testIsCurrentClipboard(self):
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        self.failUnless(pythoncom.OleIsCurrentClipboard(do))
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testComToWin32(self):
        # Set the data via our DataObject
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        # Then get it back via the standard win32 clipboard functions.
        win32clipboard.OpenClipboard()
        got = win32clipboard.GetClipboardData(win32con.CF_TEXT)
        # CF_TEXT gives bytes on py3k - use str2bytes() to ensure that's true.
        expected = str2bytes("Hello from Python")
        self.assertEqual(got, expected)
        # Now check unicode
        got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
        self.assertEqual(got, u"Hello from Python")
        win32clipboard.CloseClipboard()
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testDataObjectFlush(self):
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        self.assertEqual(num_do_objects, 1)

        do = None # clear my ref!
        pythoncom.OleFlushClipboard()
        self.assertEqual(num_do_objects, 0)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)

    #  Retrieves the display name for the specified file object or subfolder.
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testIsCurrentClipboard(self):
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        self.failUnless(pythoncom.OleIsCurrentClipboard(do))
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testComToWin32(self):
        # Set the data via our DataObject
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        # Then get it back via the standard win32 clipboard functions.
        win32clipboard.OpenClipboard()
        got = win32clipboard.GetClipboardData(win32con.CF_TEXT)
        # CF_TEXT gives bytes on py3k - use str2bytes() to ensure that's true.
        expected = str2bytes("Hello from Python")
        self.assertEqual(got, expected)
        # Now check unicode
        got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
        self.assertEqual(got, u"Hello from Python")
        win32clipboard.CloseClipboard()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testDataObjectFlush(self):
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        self.assertEqual(num_do_objects, 1)

        do = None # clear my ref!
        pythoncom.OleFlushClipboard()
        self.assertEqual(num_do_objects, 0)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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)

    #  Retrieves the display name for the specified file object or subfolder.
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testIsCurrentClipboard(self):
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        self.failUnless(pythoncom.OleIsCurrentClipboard(do))
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testComToWin32(self):
        # Set the data via our DataObject
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        # Then get it back via the standard win32 clipboard functions.
        win32clipboard.OpenClipboard()
        got = win32clipboard.GetClipboardData(win32con.CF_TEXT)
        # CF_TEXT gives bytes on py3k - use str2bytes() to ensure that's true.
        expected = str2bytes("Hello from Python")
        self.assertEqual(got, expected)
        # Now check unicode
        got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
        self.assertEqual(got, "Hello from Python")
        win32clipboard.CloseClipboard()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testDataObjectFlush(self):
        do = TestDataObject("Hello from Python")
        do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject)
        pythoncom.OleSetClipboard(do)
        self.assertEqual(num_do_objects, 1)

        do = None # clear my ref!
        pythoncom.OleFlushClipboard()
        self.assertEqual(num_do_objects, 0)