473,738 Members | 11,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert a raw pointer to IDispatch

Hi,

I am trying to use the function "CreateStreamOn HGlobal" from python code
(I need to pass an IStream object to MSXML, like I do in C++ code).

I was able to retrieve a pointer on the IStream object in this way:

from ctypes import *

stream = c_int()
windll.ole32.Cr eateStreamOnHGl obal(c_long(0), c_long(1), byref(stream))
print "%x"%stream.val ue

The problem is that I would like to attach this pointer to a python
IDispatch object (in Python only, not using a C++ DLL to do the stuff).
Do you know a way to do it ?

Thanks for your attention.
Jul 18 '05 #1
3 2783
Roger That <fa********@fre e.fr> writes:
Hi,

I am trying to use the function "CreateStreamOn HGlobal" from python
code (I need to pass an IStream object to MSXML, like I do in C++
code).

I was able to retrieve a pointer on the IStream object in this way:

from ctypes import *

stream = c_int()
windll.ole32.Cr eateStreamOnHGl obal(c_long(0), c_long(1), byref(stream))
print "%x"%stream.val ue

The problem is that I would like to attach this pointer to a python
IDispatch object (in Python only, not using a C++ DLL to do the
stuff). Do you know a way to do it ?


What do you want to do with this pointer? Pass it to a function called
via ctypes?

Thomas
Jul 18 '05 #2
Le Thu, 17 Feb 2005 19:22:16 +0100, Thomas Heller s'est écrié:
from ctypes import *

stream = c_int()
windll.ole32.Cr eateStreamOnHGl obal(c_long(0), c_long(1), byref(stream))
print "%x"%stream.val ue

What do you want to do with this pointer? Pass it to a function called via
ctypes?


Once it is a IDispatch object (like the IDispatch object returned by
"win32com.clien t.Dispatch"), I will call the IStream methods on it and
pass it to a DOMDocument of MSXML. It should look like that:

stream = c_int()
windll.ole32.Cr eateStreamOnHGl obal(c_long(0), c_long(1), byref(stream))
stream_obj = some_conversion (stream)
# IDispatch call
stream_obj.Writ e("some data", 9)

doc = win32com.client .Dispatch("MSXM L2.DOMDocument. 4.0")
doc.load(stream _obj)
Jul 18 '05 #3
Le Thu, 17 Feb 2005 19:22:16 +0100, Thomas Heller a écrit*:
I am trying to use the function "CreateStreamOn HGlobal" from python code
(I need to pass an IStream object to MSXML, like I do in C++ code).

I was able to retrieve a pointer on the IStream object in this way:

from ctypes import *

stream = c_int()
windll.ole32.Cr eateStreamOnHGl obal(c_long(0), c_long(1), byref(stream))
print "%x"%stream.val ue

The problem is that I would like to attach this pointer to a python
IDispatch object (in Python only, not using a C++ DLL to do the stuff).
Do you know a way to do it ?


What do you want to do with this pointer? Pass it to a function called via
ctypes?

Once it is a IDispatch object (like the IDispatch object returned by
"win32com.clien t.Dispatch"), I will call the IStream methods on it and
pass it to a DOMDocument of MSXML. It should look like that:

stream = c_int()
windll.ole32.Cr eateStreamOnHGl obal(c_long(0), c_long(1), byref(stream))
stream_obj = some_conversion (stream)
# IDispatch call
stream_obj.Writ e("some data", 9)

doc = win32com.client .Dispatch("MSXM L2.DOMDocument. 4.0")
doc.load(stream _obj)

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4541
by: Peter Sparago | last post by:
I am working with the MSHTML editor control. I used win32com.client.gencache.EnsureModule on the MSHTML type library to generate the necessary IDispatch support for all the various interfaces used by MSHTML. I have just implemented some of the necessary custom COM interfaces/gateways to allow me to take control of MSHTML's right-click menu. One of the callbacks that MSHTML makes (and I've implemented) is
10
4389
by: Simon | last post by:
I'm a js newbie trying to use some very simple js to call an ActiveX object's methods. I need to use a pointer to call an embedded ActiveX object's method to receive a number. As I understand it, js is typeless so how can I get a variable to be a pointer type? Passing var i as the parameter gets an undefined value in return. Thanks IA, Simon
5
3401
by: Dominic Godin | last post by:
Hi, I have decleared the IDispatch interface but I'm having trouble using it. Word.Application MSWord = new Word.ApplicationClass(); IDispatch wb = (IDispatch)MSWord.WordBasic; int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID; string rgsNames = {"DisableAutoMacros"};
1
15648
by: Dmitry Medvedev | last post by:
Hello, I need to write C# class, that would implement IDispatch interface to be used in ActiveScript. I can't use IReflect interface here due to design issues, I need to handle GetIDsOfNames and Invoke manually. I've tried the following code:
4
5412
by: Phil Coveney | last post by:
Hello, I am implementing a class in C# that wraps an automation server and am stuck on something basic. Using the following code fragment: using System; using System.Runtime.InteropServices; namespace ANamespace {
0
3472
by: Jim Hubbard | last post by:
How would I implement the IDispatch interface to handle the following in VB.Net <BEGIN> Controlling Download and Execution The WebBrowser Control gives you control over what it downloads, displays, and executes. To gain this control, you need to implement your host's IDispatch so it handles DISPID_AMBIENT_DLCONTROL. When the WebBrowser Control is instantiated, it will call your IDispatch::Invoke with this ID. Set pvarResult to a...
3
2418
by: ZhaoYingpu | last post by:
Hello,all I am using win32com to use com. and invoke a method as follows: void AddShapeInfo(LPCTSTR name, LONG type, IDispatch* pDisp); but i pass 0 or None to third parameter and get error info: Traceback (most recent call last): File "<pyshell#9>", line 1, in <module> x.AddShapeInfo("who", 10, 0) File "<COMObject xxx.Document>", line 2, in AddShapeInfo
0
966
by: Brad Johnson | last post by:
I have a C++ application that creates a collection of COM objects. I would like to give the Python interpreter access to these interfaces that were created in C++ land. Stated another way, how can I have Python consume a IDispatch pointer from C++ and wrap it with one of those nice Python classes automatically? Thanks in advance.
3
2737
by: Huayang Xia | last post by:
I am trying to use ctypes to call dll functions. One of the functions requires argument "struct IDispatch* ". I do have a PyIDispatch object in python. How can I convert this "PyIDispatch object" to "struct IDispatch* "? Thanks in advance.
0
8969
marktang
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...
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9263
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,...
0
6053
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();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.