Reputation: 2488
I have a C function in a DLL which looks like this.
ProcessAndsend(Format *out, // IN
char const *reqp, // IN
size_t reqLen, // IN
Bool *Status, // OUT
char const **reply, // OUT
size_t *resLen) // OUT
When the call is successful something get saved to all the OUT parameters.
Using python ctypes (On Windows) I want to double de-reference the **reply pointer and see what is the value there.
Thanks in Adv.
Upvotes: 1
Views: 1236
Reputation: 177600
I don't have your Format
and Bool
types, so with some substitutions, here's some sample DLL code:
#include <stddef.h>
__declspec(dllexport) void ProcessAndsend(char *out, // IN
char const *reqp, // IN
size_t reqLen, // IN
int *Status, // OUT
char const **reply, // OUT
size_t *resLen) // OUT
{
*Status = 1;
*reply = "test";
*resLen = 5;
}
This will retrieve the output data. Just create some instances of the correct ctypes types and pass them by reference:
>>> from ctypes import *
>>> dll = CDLL('your.dll')
>>> f = dll.ProcessAndsend
>>> f.argtypes = c_char_p,c_char_p,c_size_t,POINTER(c_int),POINTER(c_char_p),POINTER(c_size_t)
>>> f.restype = None
>>> status = c_int()
>>> reply = c_char_p()
>>> size = c_size_t()
>>> f('abc','def',3,byref(status),byref(reply),byref(size))
>>> status
c_long(1)
>>> reply
c_char_p('test')
>>> size
c_ulong(5L)
Upvotes: 3