Lenard Lindstrom | 1 Feb 2008 04:42

Re: Calling X11's XChangeProperty

Welch, Donald J wrote:
> Hello,
>  
> I am trying to wrap X11's XChangeProperty API. What I'm having issues 
> with is the (uchar *)data parameter. I am trying to convert code that 
> looks like:
>  
> int data = 1;
> r = XInternAtom(...)
> XChangeProperty(dsp, win, r, r, 32, 0, (uchar *)&data, 0)
>  
> I specified the argtype for the data param as: c_char_p (there doesn't 
> seem to be a c_uchar_p type?)
>  
> I've tried various combinations of pointer(), c_char_p, POINTER(), 
> etc. to massage the data value with no luck. Also, I do not understand 
> how to limit the data width to 32, as specified by the 32 in the call. 
> On a 64bit machine, an int can be 64 bits, right? 
>  
First, only use c_char_p where a foreign function can except a string 
literal as an argument. The (uchar *) parameter looks like it might pass 
out a value, so c_char_p is inappropriate. Instead declare the argument 
as a pointer, POINTER(c_byte), where c_byte is unsigned char. Second, 
you cannot use a Python int, a constant, as a parameter in this case. 
Use a mutable ctypes type instance. c_int32 is what you want since a C 
int is only guaranteed to be at least a 16 bit integer. Putting it all 
together:

XChangeProperty.argtypes = [...., POINTER(c_byte), ...]

(Continue reading)

Jason Bowsher | 1 Feb 2008 19:24
Picon

Hoe can an array of doubles be passed to a C++ DLL to be populated

Hi All

Is any able to suggest how I can pass a pointer to an array of doubles to a c++ DLL which will populate the array elements.  The the python script will be able to print out the data in the populated array.

 

However I get the following errors for the example below.  Any help appreciated.

 

Jason

 

The example code I have tried is:

On the C++ side for TestProject.DLL

extern

"C" __declspec(dllexport) int popArray(double *myArray);

int

popArray(double *myArray){

myArray[0]=0.001;

myArray[1]=0.012;

return int(0);

}

 

On the Python Side:

from ctypes import *

# load dll
myDLL = windll.LoadLibrary("TestProject.DLL")
myDLL.popArray.restype= c_int
myDLL.popArray.argtype = [POINTER(c_double)]

myArray=c_double * 2

print 'myArray is', myArray

#intRes=myDLL.popArray(byref(myArray))
#intRes=myDLL.popArray(POINTER(myArray))
#intRes=myDLL.popArray(pointer(myArray))
intRes=myDLL.popArray(myArray)

print 'myArray is now', myArray

Have tired each of the 4 examples above and get the following errors respectively:

myArray is <class '__main__.c_double_Array_2'>
Traceback (most recent call last):
  File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 13, in <module>
    intRes=myDLL.popArray(byref(myArray))
TypeError: byref() argument must be a ctypes instance, not '_ctypes.ArrayType'

or

myArray is <class '__main__.c_double_Array_2'>
Traceback (most recent call last):
  File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 14, in <module>
    intRes=myDLL.popArray(POINTER(myArray))
ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know how to convert parameter 1

or

Traceback (most recent call last):
  File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 15, in <module>
    intRes=myDLL.popArray(pointer(myArray))
  File "C:\Python25\lib\ctypes\__init__.py", line 310, in pointer
    return POINTER(type(inst))(inst)
  File "C:\Python25\lib\ctypes\__init__.py", line 254, in POINTER
    {'_type_': cls})
TypeError: _type_ must have storage info

or

Traceback (most recent call last):
  File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 16, in <module>
    intRes=myDLL.popArray(myArray)
ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know how to convert parameter 1


-- --
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Tibor Horvath | 1 Feb 2008 19:33

Re: Hoe can an array of doubles be passed to a C++ DLL to be populated

Jason Bowsher wrote:
>     Hi All
> 
>     Is any able to suggest how I can pass a pointer to an array of
>     doubles to a c++ DLL which will populate the array elements.  The
>     the python script will be able to print out the data in the
>     populated array.
> 
>      
> 
>     However I get the following errors for the example below.  Any help
>     appreciated.
> 
>      
> 
>     Jason
> 
>      
> 
>     The example code I have tried is:
> 
>     On the C++ side for TestProject.DLL
> 
>     extern "C" __declspec(dllexport) int popArray(double *myArray);
> 
>     int popArray(double *myArray){
> 
>     myArray[0]=0.001;
> 
>     myArray[1]=0.012;
> 
>     return int(0);
> 
>     }
> 
>      
> 
>     On the Python Side:
> 
>     from ctypes import *
> 
>     # load dll
>     myDLL = windll.LoadLibrary("TestProject.DLL")
>     myDLL.popArray.restype= c_int
>     myDLL.popArray.argtype = [POINTER(c_double)]

It should be "argtypes", not "argtype".

> 
>     myArray=c_double * 2
> 
>     print 'myArray is', myArray
> 
>     #intRes=myDLL.popArray(byref(myArray))
>     #intRes=myDLL.popArray(POINTER(myArray))
>     #intRes=myDLL.popArray(pointer(myArray))
>     intRes=myDLL.popArray(myArray)
> 
>     print 'myArray is now', myArray
> 
>     Have tired each of the 4 examples above and get the following errors
>     respectively:
> 
>     myArray is <class '__main__.c_double_Array_2'>
>     Traceback (most recent call last):
>       File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 13, in
>     <module>
>         intRes=myDLL.popArray(byref(myArray))
>     TypeError: byref() argument must be a ctypes instance, not
>     '_ctypes.ArrayType'
> 
>     or
> 
>     myArray is <class '__main__.c_double_Array_2'>
>     Traceback (most recent call last):
>       File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 14, in
>     <module>
>         intRes=myDLL.popArray(POINTER(myArray))
>     ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know
>     how to convert parameter 1
> 
>     or
> 
>     Traceback (most recent call last):
>       File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 15, in
>     <module>
>         intRes=myDLL.popArray(pointer(myArray))
>       File "C:\Python25\lib\ctypes\__init__.py", line 310, in pointer
>         return POINTER(type(inst))(inst)
>       File "C:\Python25\lib\ctypes\__init__.py", line 254, in POINTER
>         {'_type_': cls})
>     TypeError: _type_ must have storage info
> 
>     or
> 
>     Traceback (most recent call last):
>       File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 16, in
>     <module>
>         intRes=myDLL.popArray(myArray)
>     ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know
>     how to convert parameter 1
> 
> 

Cheers,
Tibor

--

-- 
Tibor Horvath
Graduate Student, Computer Science
University of Virginia
http://www.cs.virginia.edu/~th8k/
Attachment (smime.p7s): application/x-pkcs7-signature, 5176 bytes
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Lenard Lindstrom | 1 Feb 2008 20:03

Re: Hoe can an array of doubles be passed to a C++ DLL to be populated

Tibor Horvath wrote:
> Jason Bowsher wrote:
>>     
[snip]
>>     
>>     On the Python Side:
>>
>>     from ctypes import *
>>
>>     # load dll
>>     myDLL = windll.LoadLibrary("TestProject.DLL")
>>     myDLL.popArray.restype= c_int
>>     myDLL.popArray.argtype = [POINTER(c_double)]
>
> It should be "argtypes", not "argtype".
>
>>
>>     myArray=c_double * 2
>>
>>     print 'myArray is', myArray
>>
>>     #intRes=myDLL.popArray(byref(myArray))
>>     #intRes=myDLL.popArray(POINTER(myArray))
>>     #intRes=myDLL.popArray(pointer(myArray))
>>     intRes=myDLL.popArray(myArray)
>>
>>     
And you want the last version, since an array is already a pointer and 
can be passed to a function expecting a pointer. The only reason it 
failed before is because argtypes was not set.

--

-- 
Lenard Lindstrom
<len-l <at> telus.net>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Diez B. Roggisch | 3 Feb 2008 15:26
Picon
Gravatar

pickling ctypes structs

Hi,

I'm running a Pyro-Server on a robot which is supposed to communicate me 
some state information. Pyro uses pickle to transfer data, and the state 
is a ctypes.Structure.

I see the data just fine on my server-side, and I don't get any errors 
unpickling client-side. And I can also access the struct-memebers.

But they are all 0.

So - is this a known limitation to ctypes-structs?

I would like to spare myself the effort of having to re-build the whole 
state-information server-side into a "pure" python-collection-based object.

Diez

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Matthias Baas | 3 Feb 2008 18:50
Picon

Is the "_type_" attribute on arrays part of the public API?

Hi,

I noticed that ctypes arrays have an attribute _type_ that is the type 
of a single item in that array. This is exactly what I need, but as the 
section on arrays in the manual is still empty and the name of that 
attribute somewhat suggests that this is a "private" attribute, I was 
wondering if this is really the recommended way to get at this 
information. So is this part of the public API and this attribute will 
continue to exist in future versions? Or how should I obtain the basic 
type that an array is composed of?

- Matthias -

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Jason Bowsher | 4 Feb 2008 10:18
Picon

Re: ctypes-users Digest, Vol 22, Issue 2

Hi All
 
Still haveing error when trying to pass a array of doubles to a C++ DLL. 
 
Below is the sample code and the associated error.
 
C++ DLL
 

extern

"C" __declspec(dllexport) int popArray(double *myArray);

int

popArray(double *myArray){

myArray[0]=0.001;

myArray[1]=0.012;

return int(0);

}

_________________
 
Calling C++ wrapper that works
 

extern

"C" __declspec(dllimport) int popArray(double *myArray);

int

main(void){

//Create an array which will be populated with the results

double result[2];

popArray(result);

return int(0);

}

___________________
 
The ptyhon caller that has the error:
 
from ctypes import *
# load mbrm dll'S
myDLL = windll.LoadLibrary("TestProject.DLL")
myDLL.popArray.restype= c_int
myDLL.popArray.argtypes = [POINTER(c_double * 2)]
myArray=(c_double * 2)()
print 'myArray is', myArray
intRes=myDLL.popArray(pointer(myArray))
print 'myArray is now', myArray
 
which generated the following error.
 
myArray is <__main__.c_double_Array_2 object at 0x01499620>
Traceback (most recent call last):
  File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 13, in <module>
    intRes=myDLL.popArray(pointer(myArray))
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
 
Can anyone suggest the cause.  Perhaps something in my C++ DLL where I do not specify a pointer to an array of doubles just to a double.
 
Regards
 
Jason

----- Original Message -----
From: ctypes-users-request <at> lists.sourceforge.net
To: ctypes-users <at> lists.sourceforge.net
Subject: ctypes-users Digest, Vol 22, Issue 2
Date: Fri, 01 Feb 2008 12:08:11 -0800


Send ctypes-users mailing list submissions to
ctypes-users <at> lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/ctypes-users
or, via email, send a message with subject or body 'help' to
ctypes-users-request <at> lists.sourceforge.net

You can reach the person managing the list at
ctypes-users-owner <at> lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of ctypes-users digest..."


Today's Topics:

1. Re: Hoe can an array of doubles be passed to a C++ DLL to be
populated (Lenard Lindstrom)


----------------------------------------------------------------------

Message: 1
Date: Fri, 01 Feb 2008 11:03:33 -0800
From: Lenard Lindstrom
Subject: Re: [ctypes-users] Hoe can an array of doubles be passed to a
C++ DLL to be populated
To: ctypes ML
Message-ID: <47A36D05.1030803 <at> telus.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Tibor Horvath wrote:
> Jason Bowsher wrote:
>>
[snip]
>>
>> On the Python Side:
>>
>> from ctypes import *
>>
>> # load dll
>> myDLL = windll.LoadLibrary("TestProject.DLL")
>> myDLL.popArray.restype= c_int
>> myDLL.popArray.argtype = [POINTER(c_double)]
>
> It should be "argtypes", not "argtype".
>
>>
>> myArray=c_double * 2
>>
>> print 'myArray is', myArray
>>
>> #intRes=myDLL.popArray(byref(myArray))
>> #intRes=myDLL.popArray(POINTER(myArray))
>> #intRes=myDLL.popArray(pointer(myArray))
>> intRes=myDLL.popArray(myArray)
>>
>>
And you want the last version, since an array is already a pointer and
can be passed to a function expecting a pointer. The only reason it
failed before is because argtypes was not set.

--
Lenard Lindstrom





------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

------------------------------

_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users


End of ctypes-users Digest, Vol 22, Issue 2
*******************************************

-- --
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Jason Bowsher | 4 Feb 2008 11:52
Picon

Re: How can an array of doubles be passed to a C++ DLL to be populated


Hi All

I seem to be getting an error when a C++ DLL is exiting aftre sucessfully updating the elements in an array of doubles passed by Python

I have tried the suggested solutions but still get the error.  Am I missing something?


On the C++ side for TestProject.DLL

extern "C" __declspec(dllexport) int popArray(double myArray[], int arraySize);

int

popArray(double myArray[], int arraySize){

int index=0;

//loop through each element of the array passed by the callingn function

//the passed in should specify the size of the array

for(index=0;index<arraySize;index++){

//verify that the element index does not exceed the array size

if(index>=0 && index<arraySize){

myArray[index]=

double(0.001+index);

}

}

//return zero if function sucessful

return int(0);

}


On the Python Side

from ctypes import *

# load mbrm dll'S
myDLL = windll.LoadLibrary("TestProject.DLL")
myDLL.popArray.restype= c_int
myDLL.popArray.argtypes = [POINTER(c_double * 2), c_int]

myArray=(c_double * 2)()
myArraySize=c_int(2)

print 'myArray is', myArray
print 'myArray element[0] is', myArray[0]

intRes=myDLL.popArray(myArray, myArraySize)

print 'myArray is now', myArray
print 'myArray element[0] is now', myArray[0]

 

 

When I run the Python Script I get:

 

myArray is <__main__.c_double_Array_2 object at 0x014985D0>
myArray element[0] is 0.0
Traceback (most recent call last):
  File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 15, in <module>
    intRes=myDLL.popArray(myArray, myArraySize)
ValueError: Procedure probably called with too many arguments (8 bytes in excess)
>>>

Can anyone tell my why it is complaining about 8 bytes in excess?

 

Regards

 

Jason


-- --
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Jason Bowsher | 4 Feb 2008 11:55
Picon

Re: How can an array of doubles be passed to a C++ DLL to be populated

OK have found the solution. needed to change
 
myDLL = windll.LoadLibrary("TestProject.DLL")

to
 
myDLL = cdll.LoadLibrary("TestProject.DLL")
----- Original Message -----
From: "Jason Bowsher"
To: ctypes-users <at> lists.sourceforge.net
Subject: RE: How can an array of doubles be passed to a C++ DLL to be populated
Date: Mon, 4 Feb 2008 10:52:16 +0000


Hi All

I seem to be getting an error when a C++ DLL is exiting aftre sucessfully updating the elements in an array of doubles passed by Python

I have tried the suggested solutions but still get the error.  Am I missing something?


On the C++ side for TestProject.DLL

extern "C" __declspec(dllexport) int popArray(double myArray[], int arraySize);

int

popArray(double myArray[], int arraySize){

int index=0;

//loop through each element of the array passed by the callingn function

//the passed in should specify the size of the array

for(index=0;index<arraySize;index++){

//verify that the element index does not exceed the array size

if(index>=0 && index<arraySize){

myArray[index]=

double(0.001+index);

}

}

//return zero if function sucessful

return int(0);

}


On the Python Side

from ctypes import *

# load mbrm dll'S
myDLL = windll.LoadLibrary("TestProject.DLL")
myDLL.popArray.restype= c_int
myDLL.popArray.argtypes = [POINTER(c_double * 2), c_int]

myArray=(c_double * 2)()
myArraySize=c_int(2)

print 'myArray is', myArray
print 'myArray element[0] is', myArray[0]

intRes=myDLL.popArray(myArray, myArraySize)

print 'myArray is now', myArray
print 'myArray element[0] is now', myArray[0]

 

 

When I run the Python Script I get:

 

myArray is <__main__.c_double_Array_2 object at 0x014985D0>
myArray element[0] is 0.0
Traceback (most recent call last):
  File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 15, in <module>
    intRes=myDLL.popArray(myArray, myArraySize)
ValueError: Procedure probably called with too many arguments (8 bytes in excess)
>>>

Can anyone tell my why it is complaining about 8 bytes in excess?

 

Regards

 

Jason


--
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!

-- --
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Peter Waller | 4 Feb 2008 13:01
Picon
Gravatar

Fwd: ctypes-users Digest, Vol 22, Issue 2

Forgot to post to group.

---------- Forwarded message ----------
From: Peter Waller <peter.waller <at> gmail.com>
Date: Feb 4, 2008 9:27 AM
Subject: Re: ctypes-users Digest, Vol 22, Issue 2
To: Jason Bowsher <jason.bowsher <at> mail.com>


intRes=myDLL.popArray(pointer(myArray))

You don't need 'pointer', just as you don't write:

int main(void){ //Create an array which will be populated with the results double
result[2];

popArray(&result); // Note the &. This is the equivalent of pointer()

return int(0);

}





On Feb 4, 2008 9:18 AM, Jason Bowsher <jason.bowsher <at> mail.com> wrote:
Hi All
 
Still haveing error when trying to pass a array of doubles to a C++ DLL. 
 
Below is the sample code and the associated error.
 
C++ DLL
 

extern

"C" __declspec(dllexport) int popArray(double *myArray);

int

popArray(double *myArray){

myArray[0]=0.001;

myArray[1]=0.012;

return int(0);

}

_________________
 
Calling C++ wrapper that works
 

extern

"C" __declspec(dllimport) int popArray(double *myArray);

int

main(void){

//Create an array which will be populated with the results

double result[2];

popArray(result);

return int(0);

}

___________________
 
The ptyhon caller that has the error:
 
from ctypes import *
# load mbrm dll'S
myDLL = windll.LoadLibrary("TestProject.DLL")
myDLL.popArray.restype= c_int
myDLL.popArray.argtypes = [POINTER(c_double * 2)]
myArray=(c_double * 2)()
print 'myArray is', myArray
intRes=myDLL.popArray(pointer(myArray))
print 'myArray is now', myArray
 
which generated the following error.
 
myArray is <__main__.c_double_Array_2 object at 0x01499620>
Traceback (most recent call last):
  File "Y:\CodeProjects\jasMBRMWrapper\debug\TEST.py", line 13, in <module>
    intRes=myDLL.popArray(pointer(myArray))
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
 
Can anyone suggest the cause.  Perhaps something in my C++ DLL where I do not specify a pointer to an array of doubles just to a double.
 
Regards
 
Jason

----- Original Message -----
From: ctypes-users-request <at> lists.sourceforge.net
To: ctypes-users <at> lists.sourceforge.net
Subject: ctypes-users Digest, Vol 22, Issue 2
Date: Fri, 01 Feb 2008 12:08:11 -0800


Send ctypes-users mailing list submissions to
ctypes-users <at> lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/ctypes-users
or, via email, send a message with subject or body 'help' to
ctypes-users-request <at> lists.sourceforge.net

You can reach the person managing the list at
ctypes-users-owner <at> lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of ctypes-users digest..."


Today's Topics:

1. Re: Hoe can an array of doubles be passed to a C++ DLL to be
populated (Lenard Lindstrom)


----------------------------------------------------------------------

Message: 1
Date: Fri, 01 Feb 2008 11:03:33 -0800
From: Lenard Lindstrom
Subject: Re: [ctypes-users] Hoe can an array of doubles be passed to a
C++ DLL to be populated
To: ctypes ML
Message-ID: <47A36D05.1030803 <at> telus.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Tibor Horvath wrote:
> Jason Bowsher wrote:
>>
[snip]
>>
>> On the Python Side:
>>
>> from ctypes import *
>>
>> # load dll
>> myDLL = windll.LoadLibrary("TestProject.DLL")
>> myDLL.popArray.restype= c_int
>> myDLL.popArray.argtype = [POINTER(c_double)]
>
> It should be "argtypes", not "argtype".
>
>>
>> myArray=c_double * 2
>>
>> print 'myArray is', myArray
>>
>> #intRes=myDLL.popArray(byref(myArray))
>> #intRes=myDLL.popArray(POINTER(myArray))
>> #intRes=myDLL.popArray(pointer(myArray))
>> intRes=myDLL.popArray(myArray)
>>
>>
And you want the last version, since an array is already a pointer and
can be passed to a function expecting a pointer. The only reason it
failed before is because argtypes was not set.

--
Lenard Lindstrom





------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

------------------------------

_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users


End of ctypes-users Digest, Vol 22, Issue 2
*******************************************

--
Want an e-mail address like mine?
Get a free e-mail account today at www.mail.com!


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users

Gmane