ctypes, accessing uInt32 and pointer to uInt32

A

Andrew Markebo

I am taking the first steps letting python access a c-function in a
..dll-file, but need some help getting it right. WHat am I missing?

---------------------------------
# Trying to access c-code placed in a DLL:
# void __stdcall F_to_C(uInt32 DegF, uInt32 *DegC);

from ctypes import *
Convert_Temp=cdll.LoadLibrary("h:/WorkingWith/PythonDLL/Convert_Temp.dll")
fahr=c_int(52)
deg=c_int()
Convert_Temp.F_to_C(fahr, byref(deg))
cdll.free_library (ConvertTemp)
----------------------------------

But the result I get is:

ValueError: Procedure called with not enough arguments (8 bytes
missing) or wrong calling convention

on the call to ConvertTemp.

If I set fahr and deg to c_long it runs but I get WindowsError:
exception: access violation writing 0x00000000


Thank you for reading..

/Andy
 
P

Peter Hansen

Andrew said:
I am taking the first steps letting python access a c-function in a
.dll-file, but need some help getting it right. WHat am I missing?

For posterity: this was also asked, and answered, in the ctypes
mailing list.

(The answer was, roughly, "__stdcall means use windll, not cdll".)

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top