accessing an OLE Automation (IDispatch) server from python which requires the use of "out params"

bitbucket coder1024 at gmail.com
Mon Dec 10 14:13:51 EST 2012


I have an existing Windows application which provides an OLE Automation (IDispatch) interface.  I'm not able to change that interface.  I'd like to call it from a scripting language.  I figure this would provide a nice quick way to invoke on the app.

I initially tried this with Windows Powershell but ran into the following problem.  I was able to create the object and invoke simple methods on it.  However the interface for this app has methods which take out params.  i.e. you pass in a reference to a variable and the server fills in the value.  I couldn't get that to work.  I finally gave up and decided it was just a limitation of Powershell, not being able to work with those out params.

My next thought was to do it in python.  I've been reading up on python and I've found a decent amount of into out there on doing OLE and I'm optimistic.  But, I thought that I'd ask the question before digging too much farther into it...

When calling an OLE Automation (IDispatch) server from python can I make use of "out params" defined by the interface?

To get more specific, here's an example from the server's IDL for one of its methods.

[id(15), helpstring("method GetSettingValue")] VARIANT_BOOL GetSettingValue(BSTR settingName, BSTR* settingValue);

As you can see, you have to pass in an out param for settingValue.  The server fills this in for you.  And this is what I couldn't get to work in Powershell.

Anyone know whether or not OLE from python will allow passing in out params?  Do you think this will work?



More information about the Python-list mailing list