Hello all,
I have developed an automation server using Mark's win32 extensions
and I must return a IStream COM object from one method of the
automation server.
Here is an extract of my code:
class Stream:
_public_methods _ = [ 'Read', 'Write', 'read', 'write',
'Seek', 'SetSize', 'CopyTo',
'Commit', 'Revert', 'LockRegion', 'UnlockRegion',
'Stat', 'Clone']
_com_interfaces _ = [ pythoncom.IID_I Stream ]
def __init__(self, mode, data):
print "init stream"
self._data = data
self._ptr = 0
self._size = len(data)
self._creationT ime = Time(time())
self._accessTim e = Time(time())
self._modificat ionTime = Time(time())
self._mode = mode
def Read(self, numBytes):
"""Read the specified number of bytes from the string"""
self._accessTim e = Time(time())
data = self._data[self._ptr:self. _ptr + numBytes]
self._ptr = self._ptr + numBytes
if self._ptr > len(self._data) : self._ptr = len(self._data) - 1
print "Read data", data
return data # string
read = Read
def Write(self, data):
"""Write data to stream"""
self._modificat ionTime = Time(time())
print "Write data", data
self._data = self._data + data
return
write = Write
def Seek(self, offset, origin):
"""Changes the seek pointer to a new location"""
self._ptr = offset + origin
return self._ptr # ULARGE_INTEGER
def SetSize(self, newSize):
"""Changes the size of the stream object."""
self._size = newSize
return
def CopyTo(self, stream, cb):
"""Copies a specified number of bytes from the
current seek pointer in the stream to the current
seek pointer in another stream"""
data = self._data[self._ptr:self. _ptr+cb]
stream.Write(da ta)
return len(data) # ULARGE_INTEGER
def Commit(self, flags):
"""Ensures that any changes made to a stream object
open in transacted mode are reflected in the parent storage"""
return
def Revert(self):
"""Discards all changes that have been made to a
transacted stream since the last PyIStream::Comm it call"""
return
def LockRegion(self , offset, cb, lockType):
"""Restrict s access to a specified range of bytes
in the stream"""
return
def UnlockRegion(se lf, offset, cb, lockType):
"""Removes the access restriction on a range of bytes
previously restricted with PyIStream::Lock Region"""
return
def Clone(self):
"""Creates a new stream object with its own seek pointer
that references the same bytes as the original stream"""
# not yet implemented
return # PyIStream
def Stat(self, grfStatFlag):
"""Returns information about the stream"""
st = ('stream', STGTY_STREAM, self._size, self._modificat ionTime,
self._creationT ime, self._accessTim e, self._mode, LOCK_EXCLUSIVE,
)
return st # STATSTG
class AutomationServe r:
def GetStream(self) :
from win32com import storagecon
_grfMode_READ = storagecon.STGM _SHARE_EXCLUSIV E | \
storagecon.STGM _DIRECT | \
storagecon.STGM _READ
_grfMode_WRITE = storagecon.STGM _SHARE_EXCLUSIV E | \
storagecon.STGM _WRITE
s = XMLRPCLib2.Stre am(_grfMode_WRI TE, '')
return wrap(s, pythoncom.IID_I Stream, useDispatcher=u seDispatcher)
I'm trying to use this automation server in the Navision ERP. Navision
accepts the return value VT_UNKNOWN and maps it to an Navision
internal type InStream or OutStream. These types must be standard
IStream COM objects.
Since I'm using a correct typelib calling GetStream does not generate
a exception, the problem appears when I call a method of the Navision
type InStream/OutStream accessing the Stream methods. The error
message says something like "The is an problem communicating with the
stream". The python trace collector says nothing.
Since there are working automation servers that returns a IStream COM
object for Navision, I think there must be an error in my Stream
class. I suppose that python maps the native IStream methods to the
PyIStream methods in order to avoid using the pointers of the native
interface.
I made some test using pythoncom._univ gw in order to create a vtable
for the IStream COM object, but the function CreateTearOff crashes
python. So, running testuniv.py after changing the line "import
univgw" to "from pythoncom import _univgw as univgw" crashes python. A
bug? Can anybody confirm this?
Can anybody help me? Maybe a working example? 0 2677 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Thomas Matthews |
last post by:
Hi,
In some threads, some people mentioned that variable initialization is
best performed in an initialization list.
Is there a way to initialize a variable from an istream in an
initialization list?
Example:
class My_Class
{
|
by: jaivrat |
last post by:
When we overload the >> operator then why do we need to return the
istream by reference ? Why can't we do a void return?
(Quoting from a book )
e.g
istream & operator >>(istream & din, VectClass &v){
for( int i=0; i<= 3; i++)
din >> v;
return din;
}
|
by: Randy |
last post by:
Is there any way to do this? I've tried tellg() followed by seekg(),
inserting the stream buffer to an ostringstream (ala os << is.rdbuf()),
read(), and having no luck.
The problem is, all of these methods EXTRACT the data at one
point or another. The other problem is there appears to be NO
WAY to get at the actual buffer pointer (char*) of the characters
in the stream. There is a way to get the streambuf object
associated with the...
|
by: Gunnar Liknes |
last post by:
Hi,
I am trying to access COM component - method that takes a IStream (ByRef)
parameter
from ASP (Not ASP.NET).
So far I have had no luck and google drowns my search with ASP.NET
examples...
I mange to create the object and call methods that returns strings (BSTR)
|
by: Peter Larsen [] |
last post by:
Hi,
I have a problem using System.Runtime.InteropServices.ComTypes.IStream.
Sample using the Read() method:
if (IStreamObject != null)
{
IntPtr readBytes = IntPtr.Zero;
IStreamObject.Read(buffer, size, readBytes);
| |
by: =?Utf-8?B?Sm9obg==?= |
last post by:
Hi all,
I am developing website application in asp.net , visual C# and atl com. I
am using atl com component in visual C# application. One of the function of
com component interface returns IStream interface.
I want to read data from that IStream interface. I am new to visual c#. I
have written some code. But, it is returning whole data. It is returning some
null characters.
|
by: Kourosh |
last post by:
Hi all,
I'm trying to call a COM function from C#
The function gets a paramter of type IStream in C++. I've found the
type System.Runtime.InteropServices.ComTypes.IStream, however I'm not
sure how to create an instance of it to pass as the parameter. Anyone
can tell me what to do? i dont know what to pass in as the parameter,
because I'm not sure how to create an instance of the "IStream" object
in C#
|
by: Ralf |
last post by:
Hallo,
I'm trying to call a COM function from C#.
The function has a parameter from the type array of IStream* (IStream**).
The COM component (out-proc-server (.exe)) has the following code:
(C++)
STDMETHODIMP CIntf::SendFiles(int noOfStreams, IUnknown** dataStreams)
{
|
by: subramanian100in |
last post by:
Below is my understanding about count algorithms.
Return type of count and count_if algorithms is
iterator_traits<InputIterator>::difference_type.
If the container contains more than 'difference_type' elements
satisfying the condition, then count and count_if algorithm cannot
return a value greater than 'difference_type'.
As an example, suppose maximum value of 'difference_type' is INT_MAX.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |