[python-win32] How to pass "out" parameter to win32com
wjh
jh_wang2004 at 163.com
Fri Jun 27 04:08:32 CEST 2014
Dears,
I have a problem with passing out type parameter to win32com function. In C# envirement one of the COM’s function prototype is:
int ActEasyIF.ReadDeviceBlock(string szDevice, int Isize, out int IpIdata);
when calling the function ,it passes a first element of a int array to the third parameter, like this:
ACTMULTILib.ActEasyIF aa = new ACTMULTILib.ActEasyIF();
aa.ReadDeviceBlock(“D0”, 10, out da[0]))
The function read 10 integer value from device’s register D0 to D9,and write those integer value to the array da, from 0 to 9 . The function run success in C#.
I call this COM function by win32comclient in python
>>> from win32com.client import Dispatch
>>> import pythoncom
>>> parser = Dispatch("ActMulti.ActEasyIF")
>>> parser.ActLogicalStationNumber = 1
>>> parser.Open()
0 #Open device success
>>> da = [0] *10
>>> parser.ReadDeviceBlock("D0", 10, da[0])
(0, 256) #read data success
>>> da #but…
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
After call the function, it returns a tuple,the first element means read success, second is value read from device’s D0 register, but the value don’t write to list da .
I think the problem is the method of passing the third parameter,but how to pass "out" parameter to win32com, is there anything hint?
Thank you very much.
Jianhua
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20140627/5fc5f14b/attachment.html>
More information about the python-win32
mailing list