我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用pythoncom.IID_IDataObject()。
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.
def testIsCurrentClipboard(self): do = TestDataObject("Hello from Python") do = WrapCOMObject(do, iid=pythoncom.IID_IDataObject) pythoncom.OleSetClipboard(do) self.failUnless(pythoncom.OleIsCurrentClipboard(do))
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()
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)
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()