[python-win32] COM server and function parameters
Mark Hammond
mhammond at skippinet.com.au
Thu Oct 2 01:19:50 CEST 2008
> Hi all,
> this is my first time here. I looked into the archive but found no
> answer to
> a question that probably is simple (I hope).
> I need to implement a COM server and I got the interface in IDL format.
> Unfortunately to me some functions have a declaration like this:
>
> HRESULT func([in] BSTR param1, [in] VARIANT_BOOL param2, [out] BSTR
> *param3);
>
> While the first two parameters should not give problems, I don't know
> how
> to translate the last one. A comment in the interface says that I need
> to
> allocate the BSTR with SysAllocString. There's a python method to do
> this?
Just return a string - pythoncom will do the SysAllocString() for you.
Please see the 'pippo' examples in the win32com directory - they show how to
hookup a typelib with your com object implementation.
ie, your methodn will take 2 args (apart from 'self') and return a string.
> Or what parameter do I get in the python function. I write a def like:
>
> def func(param1, param2, param3):
> pass
>
>
> And on the same line I have a function declared as:
>
> HRESULT func2([out] IEnumString ** param1);
>
> Again I don't know how to handle the param.
>
> Excuse me if the question is trivial and thanks for any help,
Similarly - just return an object. In this case you need to return a Python
instance that implemented IEnumString.
Cheers,
Mark
More information about the python-win32
mailing list