PythonCOM Problem: Automating WinFAX from Python
Stefan Schukat
SSchukat at dspace.de
Thu May 23 03:12:06 EDT 2002
Hi Tino,
this is a property with an parameter. Since in Python is
no concept like call by reference. You have to use the
makepy generated wrapper (Either by makepy or EnsureDispatch) to call
such a function. This wrapper translates the call to:
>>> Result, Status = appObj.GetAutoRecieve(Device, Status)
Why there is a typeerror depends on the implementing object.
I must have a look at the makepy wrapper to tell you more.
Stefan
-----Original Message-----
From: Tino Lange [mailto:tl_news at nexgo.de]
Sent: Wednesday, May 22, 2002 7:15 PM
To: Stefan Schukat
Subject: Re: PythonCOM Problem: Automating WinFAX from Python
On Wed, 22 May 2002 08:51:33 +0100, Stefan Schukat
<SSchukat at dspace.de> wrote:
>>How can I translate the following C++-Code to python?
>>
>>// Create application object
>>if (m_sendObj.CreateDispatch("WinFax.SDKSend"))
>>{
>> m_appObj.AttachDispatch(m_sendObj.GetApplication());
>> m_appObj.LeaveRunning(1);
>> m_sendObj.ReleaseDispatch();
>> ...
>>}
> In Python this is done, so the translated code would be:
>
>>>> import win32com
>>>> import win32com.client
>>>> send_obj = win32com.client.Dispatch("WinFax.SDKSend")
>>>> appObj = send_obj.Application
>>>> appObj.LeaveRunning(1)
>>>> del send_obj
Hi Stefan!
Thanks a lot for your help! This really works now!
But it just raises the next question - maybe you or someone else can
help again? :-)
The function I want to use now on the "appObj" is "GetAutoRecieve()".
It's signature in C++ is
short GetAutoRecieve(LPCTSTR sDevice, short FAR * nStatus)
How can I code this in Python? How to emulate a pointer to an integer?
I tried
>>> nStatus = 0
>>> appObj.GetAutoReceive(u'MicroLink Office', nStatus)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<COMObject <unknown>>", line 2, in GetAutoReceive
pywintypes.com_error: (-2147352571, 'Typkonflikt.', None, 2)
>>>
with or without unicode string and with/without using "id(object)"
(pointer type?) instead of the object itself. But I always get
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<COMObject <unknown>>", line 2, in GetAutoReceive
pywintypes.com_error: (-2147352571, 'Typkonflikt.', None, 2)
Could you give me another hint?
Thanks a lot!
Tino
More information about the Python-list
mailing list