I am trying to call functions from a DLL

`function oziRepositionWP(Number:integer;lat,lon:double):integer;stdcall; `

I have written the code in python

no = c_int(1)
lat = c_double(34.00962)
lon = c_double(74.80067)

var =windll.OziAPI.oziRepositionWP(byref(no),byref(lat),byref(lon))

But i get the message

var =windll.OziAPI.oziRepositionWP(byref(no),byref(lat),byref(lon))
ValueError: Procedure probably called with not enough arguments (8 bytes missing)

where am i going wrong please help

You are trying to call by reference, when parameters are by value. Integer is not standard C type, how is it defined.

Check out your python documentation under 'ctypes'

or use:

import ctypes
help('ctypes')

Here is a typical example of a DLL call:

'''cfunc_strchr1.py
Windows DLL msvcrt.dll contains most C functions

import the C function
char* strchr(const char* cs, int c);
which returns a pointer to first occurrence of c in cs (NULL if not found)
see
http://www.csse.uwa.edu.au/programming/ansic-library.html#string

use ctypes to assign proper variable types
tested with Python32
'''

import ctypes
from ctypes import *

# accessing C functions from msvcrt.dll
# import the C function strchr() from msvcrt.dll
strchr = cdll.msvcrt.strchr

# declare the return type ...
# a 'pointer to a string' converts to a Python byte string
strchr.restype = c_char_p

# these are the argument types ...
# Python byte string converts to 'pointer to a string' --> c_char_p
# Python single char byte string converts to C char --> c_char
strchr.argtypes = [c_char_p, c_char]

# now call the function and show the result
#result = strchr(b'abcdefg', ord('d'))
# or
result = strchr(b'abcdefg', b'd')
print("C function strchr(\"abcdefg\", 'd') --> %s" % result)

# convert to a regular Python string
s = result.decode("utf8")
print(s)

'''
C function strchr("abcdefg", 'd') --> b'defg'
defg
'''
help('ctypes')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.