PythonCOM Problem: Automating WinFAX from Python

Tino Lange tl_news at nexgo.de
Wed May 22 14:15:24 EDT 2002


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