473,698 Members | 2,554 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 2779
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
4535
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
4385
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
3398
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
15645
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
5407
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
3467
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
2416
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
964
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
2734
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
8612
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,...
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
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...
1
8905
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
8880
tracyyun
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...
0
4373
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...
1
3053
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
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
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.