Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34651
| Date | 2012-12-12 08:55 +1100 |
|---|---|
| From | Mark Hammond <mhammond@skippinet.com.au> |
| Subject | Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" |
| References | <38a14001-82b6-4a91-b3ad-2cb5c8ee580d@googlegroups.com> <mailman.682.1355173145.29569.python-list@python.org> <ed7dd76c-c1f2-4d33-9e14-41e8be65c29a@googlegroups.com> <mailman.704.1355188608.29569.python-list@python.org> <5b228557-2788-4243-b840-5c8aa03d5423@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.747.1355262914.29569.python-list@python.org> (permalink) |
On 12/12/2012 2:48 AM, bitbucket wrote:
> On Monday, December 10, 2012 8:16:43 PM UTC-5, Mark Hammond wrote:
>> "out" params are best supported if the object supplied a typelib -
>> then Python knows the params are out and does the right thing
>> automagically. If out params are detected, the result of the
>> function will be a tuple of (real_result, out_param1, ...)
>>
>> Even if no typelib is supported, you can access them with a little
>> pain via the win32com.client.Dispatch() object. You might like to
>> follow up to the python-win32@python.org mailing list where many
>> people will be able to help.
>>
>> HTH,
>>
>> Mark
>
> Mark, thanks for the reply. In this case, I have a type library and
> attempted to use MakePy but it doesn't seem to be working as
> expected.
>
> I was reading through CH12 of your Python Programming on Win32 book
> (http://oreilly.com/catalog/pythonwin32/chapter/ch12.html). I was
> hopeful given your description of MakePy that I could get this to
> work. It appears that you're saying MakePy will convert "byref" args
> in a function over to return values.
>
> For example, the IDL in the server includes the following 3
> functions.
>
> [id(1)] void ShowMessage(BSTR msg); [id(2)] void GetSettingValue(BSTR
> settingName, BSTR* settingValue); [id(3)] void SetSettingValue(BSTR
> settingName, BSTR settingValue);
>
> The thorny one is the GetSettingValue since it takes the out param.
> When I run MakePy, it generates the below.
>
> def ShowMessage(self, msg=defaultNamedNotOptArg): return
> self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((8, 0),),msg )
>
> def GetSettingValue(self, settingName=defaultNamedNotOptArg,
> settingValue=defaultNamedNotOptArg): return
> self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), ((8, 0), (16392,
> 0)),settingName , settingValue)
>
> def SetSettingValue(self, settingName=defaultNamedNotOptArg,
> settingValue=defaultNamedNotOptArg): return
> self._oleobj_.InvokeTypes(3, LCID, 1, (24, 0), ((8, 0), (8,
> 0)),settingName , settingValue)
>
> I noticed that the argument type is different for the out param
> (16392 instead of 8). However, it doesn't appear to me that its
> generating return values instead of args (though I'm not very
> experienced in python).
>
> I tried invoking these in python. The ShowMessage and
> SetSettingValue work great. I can't get the GetSettingValue to work
> though. Perhaps there's a different syntax I need when using the
> MakePy generated code?
Seeing the "real" return value is void, it should just be a matter of:
settingValue = ob.GetSettingValue("settingName")
Mark
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-10 11:13 -0800
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Terry Reedy <tjreedy@udel.edu> - 2012-12-10 15:58 -0500
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-10 13:39 -0800
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-12-10 18:39 -0500
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Mark Hammond <skippy.hammond@gmail.com> - 2012-12-11 12:16 +1100
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:48 -0800
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:54 -0800
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:54 -0800
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Mark Hammond <mhammond@skippinet.com.au> - 2012-12-12 08:55 +1100
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:48 -0800
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-10 13:39 -0800
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Paul Kölle <paul@subsignal.org> - 2012-12-11 09:42 +0100
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:37 -0800
Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:37 -0800
csiph-web