Handing over string value fails

[email protected]
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
Hi All,

the following function

dllfunc(int dllHandle, const char *dllParam1, const char *dllParam2)

shall be called using ctypes.

I have the following code:

lib = ctypes.LoadLibrary("win.dll")

def pyfunc(pyHandle, pyParam1, pyParam2):
   INT = ctypes.c_int
   PCHAR = ctypes.c_char_p

   lib.artypes = (INT, PCHAR, PCHAR)

   p1 = ctypes.create_char_buffer(pyParam1)
   p2 = ctypes.create_char_buffer(pyParam2)

   returnCode = lib.dllfunc(pyHandle, ctypes.byref(p1), ctypes.byref(p1))

   return returnCode

pyfunc(pyHandle = 1, pyParam1 = "value1", pyParam2 = "value2")

The returnCode is always an error saying that the value of pyParam1 could not be found.

What do I do wrong?

Regards

George


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.