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

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

项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def update_colinfo(not_used, dir_name, fnames):
    for fname in fnames:
        full_fname=os.path.join(dir_name,fname)
        if os.path.isdir(full_fname):
            print full_fname
            pidl=shell.SHILCreateFromPath(full_fname,0)[0]
            pb=shell.SHGetViewStatePropertyBag(pidl, "Shell", shellcon.SHGVSPB_FOLDERNODEFAULTS, pythoncom.IID_IPropertyBag)
            ## not all folders already have column info, and we're replacing it anyway
            pb.Write('ColInfo', template_stream)
            iunk=pb.Read('ColInfo',pythoncom.VT_UNKNOWN)
            s=iunk.QueryInterface(pythoncom.IID_IStream)
            s.Write(template_colinfo)
            s=None
            ## attribute names read from registry, can't find any way to enumerate IPropertyBag
            for attr in ('Address','Buttons','Col','Vid','WFlags','FFlags','Sort','SortDir','ShowCmd','FolderType','Mode','Rev'):
                pb.Write(attr, template_pb.Read(attr))
            pb=None
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def TestVTableMI():
    clsctx = pythoncom.CLSCTX_SERVER
    ob = pythoncom.CoCreateInstance("Python.Test.PyCOMTestMI", None, clsctx, pythoncom.IID_IUnknown)
    # This inherits from IStream.
    ob.QueryInterface(pythoncom.IID_IStream)
    # This implements IStorage, specifying the IID as a string
    ob.QueryInterface(pythoncom.IID_IStorage)
    # IDispatch should always work
    ob.QueryInterface(pythoncom.IID_IDispatch)

    iid = pythoncom.InterfaceNames["IPyCOMTest"]
    try:
        ob.QueryInterface(iid)
    except TypeError:
        # Python can't actually _use_ this interface yet, so this is
        # "expected".  Any COM error is not.
        pass
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def TestVTableMI():
    clsctx = pythoncom.CLSCTX_SERVER
    ob = pythoncom.CoCreateInstance("Python.Test.PyCOMTestMI", None, clsctx, pythoncom.IID_IUnknown)
    # This inherits from IStream.
    ob.QueryInterface(pythoncom.IID_IStream)
    # This implements IStorage, specifying the IID as a string
    ob.QueryInterface(pythoncom.IID_IStorage)
    # IDispatch should always work
    ob.QueryInterface(pythoncom.IID_IDispatch)

    iid = pythoncom.InterfaceNames["IPyCOMTest"]
    try:
        ob.QueryInterface(iid)
    except TypeError:
        # Python can't actually _use_ this interface yet, so this is
        # "expected".  Any COM error is not.
        pass
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def update_colinfo(not_used, dir_name, fnames):
    for fname in fnames:
        full_fname=os.path.join(dir_name,fname)
        if os.path.isdir(full_fname):
            print full_fname
            pidl=shell.SHILCreateFromPath(full_fname,0)[0]
            pb=shell.SHGetViewStatePropertyBag(pidl, "Shell", shellcon.SHGVSPB_FOLDERNODEFAULTS, pythoncom.IID_IPropertyBag)
            ## not all folders already have column info, and we're replacing it anyway
            pb.Write('ColInfo', template_stream)
            iunk=pb.Read('ColInfo',pythoncom.VT_UNKNOWN)
            s=iunk.QueryInterface(pythoncom.IID_IStream)
            s.Write(template_colinfo)
            s=None
            ## attribute names read from registry, can't find any way to enumerate IPropertyBag
            for attr in ('Address','Buttons','Col','Vid','WFlags','FFlags','Sort','SortDir','ShowCmd','FolderType','Mode','Rev'):
                pb.Write(attr, template_pb.Read(attr))
            pb=None
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def TestVTableMI():
    clsctx = pythoncom.CLSCTX_SERVER
    ob = pythoncom.CoCreateInstance("Python.Test.PyCOMTestMI", None, clsctx, pythoncom.IID_IUnknown)
    # This inherits from IStream.
    ob.QueryInterface(pythoncom.IID_IStream)
    # This implements IStorage, specifying the IID as a string
    ob.QueryInterface(pythoncom.IID_IStorage)
    # IDispatch should always work
    ob.QueryInterface(pythoncom.IID_IDispatch)

    iid = pythoncom.InterfaceNames["IPyCOMTest"]
    try:
        ob.QueryInterface(iid)
    except TypeError:
        # Python can't actually _use_ this interface yet, so this is
        # "expected".  Any COM error is not.
        pass
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def update_colinfo(not_used, dir_name, fnames):
    for fname in fnames:
        full_fname=os.path.join(dir_name,fname)
        if os.path.isdir(full_fname):
            print(full_fname)
            pidl=shell.SHILCreateFromPath(full_fname,0)[0]
            pb=shell.SHGetViewStatePropertyBag(pidl, "Shell", shellcon.SHGVSPB_FOLDERNODEFAULTS, pythoncom.IID_IPropertyBag)
            ## not all folders already have column info, and we're replacing it anyway
            pb.Write('ColInfo', template_stream)
            iunk=pb.Read('ColInfo',pythoncom.VT_UNKNOWN)
            s=iunk.QueryInterface(pythoncom.IID_IStream)
            s.Write(template_colinfo)
            s=None
            ## attribute names read from registry, can't find any way to enumerate IPropertyBag
            for attr in ('Address','Buttons','Col','Vid','WFlags','FFlags','Sort','SortDir','ShowCmd','FolderType','Mode','Rev'):
                pb.Write(attr, template_pb.Read(attr))
            pb=None
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def TestVTableMI():
    clsctx = pythoncom.CLSCTX_SERVER
    ob = pythoncom.CoCreateInstance("Python.Test.PyCOMTestMI", None, clsctx, pythoncom.IID_IUnknown)
    # This inherits from IStream.
    ob.QueryInterface(pythoncom.IID_IStream)
    # This implements IStorage, specifying the IID as a string
    ob.QueryInterface(pythoncom.IID_IStorage)
    # IDispatch should always work
    ob.QueryInterface(pythoncom.IID_IDispatch)

    iid = pythoncom.InterfaceNames["IPyCOMTest"]
    try:
        ob.QueryInterface(iid)
    except TypeError:
        # Python can't actually _use_ this interface yet, so this is
        # "expected".  Any COM error is not.
        pass
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testLogger():
        assert not hasattr(win32com, "logger")
        handler = TestLogHandler()
        formatter = logging.Formatter('%(message)s')
        handler.setFormatter(formatter)
        log = logging.getLogger("win32com_test")
        log.addHandler(handler)
        win32com.logger = log
        # Now throw some exceptions!
        # Native interfaces
        com_server = wrap(TestServer(), pythoncom.IID_IStream)
        try:
            com_server.Commit(0)
            raise RuntimeError("should have failed")
        except pythoncom.error:
            pass
        assert handler.num_emits == 1, handler.num_emits
        handler.num_emits = 0 # reset

        com_server = Dispatch(wrap(TestServer()))
        try:
            com_server.Commit(0)
            raise RuntimeError("should have failed")
        except pythoncom.error:
            pass
        assert handler.num_emits == 1, handler.num_emits
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testit(self):
        mydata = str2bytes('abcdefghijklmnopqrstuvwxyz')

        # First test the objects just as Python objects...
        s = Stream(mydata)
        p = Persists()

        p.Load(s)
        p.Save(s, 0)
        self.assertEqual(s.data, mydata)

        # Wrap the Python objects as COM objects, and make the calls as if
        # they were non-Python COM objects.
        s2 = win32com.server.util.wrap(s, pythoncom.IID_IStream)
        p2 = win32com.server.util.wrap(p, pythoncom.IID_IPersistStreamInit)

        self._readWrite(mydata, s, s)
        self._readWrite(mydata, s, s2)
        self._readWrite(mydata, s2, s)
        self._readWrite(mydata, s2, s2)

        self._readWrite(str2bytes("string with\0a NULL"), s2, s2)
        # reset the stream
        s.Write(mydata)
        p2.Load(s2)
        p2.Save(s2, 0)
        self.assertEqual(s.data, mydata)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testseek(self):
        s = Stream(str2bytes('yo'))
        s = win32com.server.util.wrap(s, pythoncom.IID_IStream)
        # we used to die in py3k passing a value > 32bits
        s.Seek(0x100000000, pythoncom.STREAM_SEEK_SET)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testerrors(self):
        # setup a test logger to capture tracebacks etc.
        records, old_log = win32com.test.util.setup_test_logger()
        ## check for buffer overflow in Read method
        badstream = BadStream('Check for buffer overflow')
        badstream2 = win32com.server.util.wrap(badstream, pythoncom.IID_IStream)
        self.assertRaises(pythoncom.com_error, badstream2.Read, 10)
        win32com.test.util.restore_test_logger(old_log)
        # expecting 2 pythoncom errors to have been raised by the gateways.
        self.assertEqual(len(records), 2)
        self.failUnless(records[0].msg.startswith('pythoncom error'))
        self.failUnless(records[1].msg.startswith('pythoncom error'))
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testLogger():
        assert not hasattr(win32com, "logger")
        handler = TestLogHandler()
        formatter = logging.Formatter('%(message)s')
        handler.setFormatter(formatter)
        log = logging.getLogger("win32com_test")
        log.addHandler(handler)
        win32com.logger = log
        # Now throw some exceptions!
        # Native interfaces
        com_server = wrap(TestServer(), pythoncom.IID_IStream)
        try:
            com_server.Commit(0)
            raise RuntimeError("should have failed")
        except pythoncom.error:
            pass
        assert handler.num_emits == 1, handler.num_emits
        handler.num_emits = 0 # reset

        com_server = Dispatch(wrap(TestServer()))
        try:
            com_server.Commit(0)
            raise RuntimeError("should have failed")
        except pythoncom.error:
            pass
        assert handler.num_emits == 1, handler.num_emits
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testit(self):
        mydata = str2bytes('abcdefghijklmnopqrstuvwxyz')

        # First test the objects just as Python objects...
        s = Stream(mydata)
        p = Persists()

        p.Load(s)
        p.Save(s, 0)
        self.assertEqual(s.data, mydata)

        # Wrap the Python objects as COM objects, and make the calls as if
        # they were non-Python COM objects.
        s2 = win32com.server.util.wrap(s, pythoncom.IID_IStream)
        p2 = win32com.server.util.wrap(p, pythoncom.IID_IPersistStreamInit)

        self._readWrite(mydata, s, s)
        self._readWrite(mydata, s, s2)
        self._readWrite(mydata, s2, s)
        self._readWrite(mydata, s2, s2)

        self._readWrite(str2bytes("string with\0a NULL"), s2, s2)
        # reset the stream
        s.Write(mydata)
        p2.Load(s2)
        p2.Save(s2, 0)
        self.assertEqual(s.data, mydata)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testseek(self):
        s = Stream(str2bytes('yo'))
        s = win32com.server.util.wrap(s, pythoncom.IID_IStream)
        # we used to die in py3k passing a value > 32bits
        s.Seek(0x100000000, pythoncom.STREAM_SEEK_SET)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testerrors(self):
        # setup a test logger to capture tracebacks etc.
        records, old_log = win32com.test.util.setup_test_logger()
        ## check for buffer overflow in Read method
        badstream = BadStream('Check for buffer overflow')
        badstream2 = win32com.server.util.wrap(badstream, pythoncom.IID_IStream)
        self.assertRaises(pythoncom.com_error, badstream2.Read, 10)
        win32com.test.util.restore_test_logger(old_log)
        # expecting 2 pythoncom errors to have been raised by the gateways.
        self.assertEqual(len(records), 2)
        self.failUnless(records[0].msg.startswith('pythoncom error'))
        self.failUnless(records[1].msg.startswith('pythoncom error'))
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testLogger():
        assert not hasattr(win32com, "logger")
        handler = TestLogHandler()
        formatter = logging.Formatter('%(message)s')
        handler.setFormatter(formatter)
        log = logging.getLogger("win32com_test")
        log.addHandler(handler)
        win32com.logger = log
        # Now throw some exceptions!
        # Native interfaces
        com_server = wrap(TestServer(), pythoncom.IID_IStream)
        try:
            com_server.Commit(0)
            raise RuntimeError("should have failed")
        except pythoncom.error:
            pass
        assert handler.num_emits == 1, handler.num_emits
        handler.num_emits = 0 # reset

        com_server = Dispatch(wrap(TestServer()))
        try:
            com_server.Commit(0)
            raise RuntimeError("should have failed")
        except pythoncom.error:
            pass
        assert handler.num_emits == 1, handler.num_emits
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testit(self):
        mydata = str2bytes('abcdefghijklmnopqrstuvwxyz')

        # First test the objects just as Python objects...
        s = Stream(mydata)
        p = Persists()

        p.Load(s)
        p.Save(s, 0)
        self.assertEqual(s.data, mydata)

        # Wrap the Python objects as COM objects, and make the calls as if
        # they were non-Python COM objects.
        s2 = win32com.server.util.wrap(s, pythoncom.IID_IStream)
        p2 = win32com.server.util.wrap(p, pythoncom.IID_IPersistStreamInit)

        self._readWrite(mydata, s, s)
        self._readWrite(mydata, s, s2)
        self._readWrite(mydata, s2, s)
        self._readWrite(mydata, s2, s2)

        self._readWrite(str2bytes("string with\0a NULL"), s2, s2)
        # reset the stream
        s.Write(mydata)
        p2.Load(s2)
        p2.Save(s2, 0)
        self.assertEqual(s.data, mydata)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testseek(self):
        s = Stream(str2bytes('yo'))
        s = win32com.server.util.wrap(s, pythoncom.IID_IStream)
        # we used to die in py3k passing a value > 32bits
        s.Seek(0x100000000, pythoncom.STREAM_SEEK_SET)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testLogger():
        assert not hasattr(win32com, "logger")
        handler = TestLogHandler()
        formatter = logging.Formatter('%(message)s')
        handler.setFormatter(formatter)
        log = logging.getLogger("win32com_test")
        log.addHandler(handler)
        win32com.logger = log
        # Now throw some exceptions!
        # Native interfaces
        com_server = wrap(TestServer(), pythoncom.IID_IStream)
        try:
            com_server.Commit(0)
            raise RuntimeError("should have failed")
        except pythoncom.error:
            pass
        assert handler.num_emits == 1, handler.num_emits
        handler.num_emits = 0 # reset

        com_server = Dispatch(wrap(TestServer()))
        try:
            com_server.Commit(0)
            raise RuntimeError("should have failed")
        except pythoncom.error:
            pass
        assert handler.num_emits == 1, handler.num_emits
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testit(self):
        mydata = str2bytes('abcdefghijklmnopqrstuvwxyz')

        # First test the objects just as Python objects...
        s = Stream(mydata)
        p = Persists()

        p.Load(s)
        p.Save(s, 0)
        self.assertEqual(s.data, mydata)

        # Wrap the Python objects as COM objects, and make the calls as if
        # they were non-Python COM objects.
        s2 = win32com.server.util.wrap(s, pythoncom.IID_IStream)
        p2 = win32com.server.util.wrap(p, pythoncom.IID_IPersistStreamInit)

        self._readWrite(mydata, s, s)
        self._readWrite(mydata, s, s2)
        self._readWrite(mydata, s2, s)
        self._readWrite(mydata, s2, s2)

        self._readWrite(str2bytes("string with\0a NULL"), s2, s2)
        # reset the stream
        s.Write(mydata)
        p2.Load(s2)
        p2.Save(s2, 0)
        self.assertEqual(s.data, mydata)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testseek(self):
        s = Stream(str2bytes('yo'))
        s = win32com.server.util.wrap(s, pythoncom.IID_IStream)
        # we used to die in py3k passing a value > 32bits
        s.Seek(0x100000000, pythoncom.STREAM_SEEK_SET)