473,382 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to Passs NULL as a IDispatch Pointer to method?

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:
>>x.AddShapeInfo("who", 10, 0)
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
com_error: (-2147352571, 'Type mismatch.', None, 3)

or
>>x.AddShapeInfo("who",0,None)
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
x.AddShapeInfo("who",0,None)
File "<COMObject xxx.Document>", line 2, in AddShapeInfo
com_error: (-2147352571, 'Type mismatch.', None, 3)

Apr 17 '07 #1
3 2401
Zh********@gmail.com wrote:
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:
>>>x.AddShapeInfo("who", 10, 0)

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
com_error: (-2147352571, 'Type mismatch.', None, 3)

or
>>>x.AddShapeInfo("who",0,None)

Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
x.AddShapeInfo("who",0,None)
File "<COMObject xxx.Document>", line 2, in AddShapeInfo
com_error: (-2147352571, 'Type mismatch.', None, 3)
Maybe Mark Hammond will chime in here, but I'll make at least an
attempt to help. If I'm reading this correctly the 3rd argument
should be and pointer to an IDispatch object. Passing null or
zero wouldn't make any sense. This looks like a pointer to a
callback function for this shape. To get one you would need to
define a Python COM class and wrap it with win32com.server.util.wrap()

possibly something like:

class who:
_public_methods_=['somemethod'}
#
# I don't know what method AddShapeInfo is going to call so
# change this to the appropriate method.
#
def somemethod(self):
#
# Put this method's code here
#
pass

#
# In your program
#
id=win32com.server.util.wrap(who())
x.AddShapeInfo("who",0,id)

I could be way off base here, but I hope that this helps.

-Larry

Apr 17 '07 #2
Thanks to Larry.
I want to pass the IDispatch pointer of other COM object to
AddShapeInfo or pass null to tell x do nothing.
for example.

Rect= Dispatch("Rect.Document")
ShapeSet = Dispatch("xxx.Document")
ShapeSet.AddShapeInfo("Rect", 0, Shape)

or

ShapeSet.AddShapeInfo("EmptyShape", 0, None)

Apr 18 '07 #3
Yingpu Zhao wrote:
Thanks to Larry.
I want to pass the IDispatch pointer of other COM object to
AddShapeInfo or pass null to tell x do nothing.
for example.

Rect= Dispatch("Rect.Document")
ShapeSet = Dispatch("xxx.Document")
ShapeSet.AddShapeInfo("Rect", 0, Shape)

or

ShapeSet.AddShapeInfo("EmptyShape", 0, None)
I think you will need to pass a basically empty class that
is wrapped in an IDispatch object. See my earlier example.

-Larry
Apr 18 '07 #4

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

Similar topics

1
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...
3
by: Roger That | last post by:
Hi, I am trying to use the function "CreateStreamOnHGlobal" 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...
69
by: Ken | last post by:
Hi all. When referring to a null pointer constant in C++, is there any reason to prefer using 0 over a macro called NULL that is defined to be 0? Thanks! Ken
1
by: Pradeep | last post by:
Hi, I am working with Intrusive pointers in a DLL and I need to set the value of the intrusive pointer to an object to NULL from inside the method of that class. So here's the scenario. I...
0
by: Pawel Janik | last post by:
Hello. I'm writing an application that calls com components. One of out parameters returns variant or type VT_DISPATCH, thast maps come C++ structure. This parameter is of System.__ComObject...
8
by: nsharma78 | last post by:
Hi, I have a code as follows: class A { public: void print(){cout << "Magic" << endl;} };
3
by: Michael | last post by:
Hi, Could you tell me how to under the following statements? Does it mean each and every memory allocation will check all the pointer no matter a null pointer or not? Right? Thanks in advance! ...
4
by: eselk | last post by:
I've got an out-of-process COM server (EXE) that I want to be able to control from Visual Basic. I can already control it from a C/C++ app without any issues. Under VBA in MS Access 2000, which I...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.