1

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.

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.