how to access character pointer value using ctypes?
<p>I have a written a DLL in which I'm getting one of the paths:</p>

<pre><code>//demo.h
__declspec(dllexport) void pathinfo(char * path);
</code></pre>

<p>Something is being done in the code to get this path.
And now, the python script that I have written to retrieve this path from the DLL is as shown:</p>

<pre><code>//demo.py
import sys 
import ctypes
from ctypes import *
class demo(object):
  def __init__(self):
     self.demoDLL=CDLL("demo.dll")

  def pathinfo(self):
     path=c_char()
     self.demoDLL.pathinfo.argtypes(POINTER(c_char))
     self.demoDLL.pathinfo.result=None
     self.demoDLL.pathinfo(byref(path))
     return path.value

if __name__=='__main__':
    abc=demo()
    path_info=abc.pathinfo()
    print "information of the path:",path_info
</code></pre>

<p>But the value that I'm able to see is just the first character of the path instead of the whole string.</p>

<p>Can anybody help me with this problem?</p>

<p>Haven't done it, but have done the following:</p>

<p>To pass an array of <code>ints</code>, for example, use this:</p>

<p>Create a type of, say, 20 ints:</p>

<pre><code>Ints20 = c_int * 20
</code></pre>

<p>Create an instance:</p>

<pre><code>data = Ints20()
</code></pre>

<p>And then you can pass <code>data</code>.
Extract the numbers from <code>data</code> by using the <code>list</code> function:</p>

<pre><code>values = list(data)
</code></pre>

<p>So may be you can do the same with chars:</p>

<pre><code>Chars20 = c_char * 20
path = Chars20()
</code></pre>

<p>and then:</p>

<pre><code>self.demoDLL.pathinfo(path)
</code></pre>

<p>In the case of c_char array there is no need to use the <code>list</code> function, but this works:</p>

<pre><code>return path.value
</code></pre>

python dll ctypes