471,123 Members | 916 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

Pythoncom: Using array of special type (com_struct) as parameter

in my Python program I have to use a COM-Server. One method of the COM
class needs a SAFEARRAY of a special type as parameter.
Trying to create such an array and calling the method results in a
Is it possible with pythoncom to use a SAFEARRAY(<mytype>)* as
parameter? If yes, how can I achieve this?

Thanks in advance, Ulf
Code pieces for demonstration:

IDL ------------
struct tagStructure {
BSTR name;
IUnknown* interface;
} SStructure;

dual, oleautomation ]
interface IManager : IDispatch {
HRESULT Init([in] long id,
[in] SAFEARRAY(SStructure)* psaInterface);

Python ---------
modtypelib = win32com.client.gencache.EnsureModule('{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}',
0, 1, 0)

mgr = win32com.client.Dispatch("ProgId")
obj = win32com.client.Dispatch("ProgId-2")
iUnk = obj._oleobj_.QueryInterface(pythoncom.IID_IUnknown )

rec = win32com.client.Record('SStructure', mgr)
rec.name = 'TheName'
rec.interface = iUnk
arr = []
mgr.Init(1, arr)

--> MemoryError: CreatingSafeArray
Jul 18 '05 #1
0 1422

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Lenard Lindstrom | last post: by
5 posts views Thread by pandapower | last post: by
8 posts views Thread by intrepid_dw | last post: by
13 posts views Thread by Kantha | last post: by
8 posts views Thread by Piotrek | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.