472,951 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

Hi,
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
MemoryError.
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 ------------
typedef [uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)]
struct tagStructure {
BSTR name;
IUnknown* interface;
} SStructure;

[ odl, uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX),
dual, oleautomation ]
interface IManager : IDispatch {
[id(0x00000001)]
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 = []
arr.append(rec)
mgr.Init(1, arr)

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul | last post by:
Hi I'm trying to build a standalone COM exe server using Python 2.2 + Mark Hammond's windows extensions + Py2Exe. I've built the example linked on the Py2Exe homepage and get this error when...
5
by: Brian Hlubocky | last post by:
I'm have a fairly simple (in terms of COM) python program that pulls info from an Access database and creates Outlook contacts from that information. It uses wxPython for gui and works without...
9
by: Lenard Lindstrom | last post by:
I was wondering if anyone has suggested having Python determine a method's kind from its first parameter. 'self' is a de facto reserved word; 'cls' is a good indicator of a class method ( __new__...
5
by: pandapower | last post by:
Hi, I know about the equivalence of pointer and arrays.But my doubt comes when its for multidimentional arrays.I have read the C faq but still have some doubts. Suppose I have a declaration as...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
13
by: Kantha | last post by:
Hi all, I have declared an Union as follows typedef union { struct interrupt_bits { unsigned char c_int_hs_fs_status : 1, c_setup_intflag : 1,
14
by: mast2as | last post by:
Hi everyone, I am trying to implement some specs which specify that an array of parameter is passed to a function as a pointer to an array terminated by a NULL chatacter. That seemed fairly easy...
8
by: Piotrek | last post by:
Hi, Like almost all of beginners I have problem understanding pointers. Please, look at this piece of code, and please explain me why myswap function doesn't work as it's supposed to do, whereas...
6
by: gcmartijn | last post by:
H! I using a script that opens a internet page in a small window (what I can control) In XP everything was working fine, but now I'm using Vista with IE7 and this is what happends now: First...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.