title: Python Ctypes Null Terminated String Block
body: <p>I am using a ctypes implementation of <a href="http://msdn.microsoft.com/en-us/library/ms682429.aspx" rel="nofollow">CreateProcessWithLogonW</a>, and everything works well except I cannot figure out how to handle this section:</p>
  
  <blockquote>
    <p>A pointer to an environment block for the new process. If this parameter is NULL, the new process uses the environment of the calling process.</p>
    
    <p>An environment block consists of a null-terminated block of null-terminated strings. Each string is in the following form:</p>
    
    <p>name=value\0</p>
  </blockquote>
  
  <p>To generated the raw string I execute the following:</p>
  
  <pre><code>lpEnvironment = '\0'.join(['%s=%s' % (k, os.environ[k]) for k in os.environ]) + '\0\0'
  print lpEnvironment
  'XAUTHORITY=/home/username/.Xauthority\x00MUTT_DIR=/home/username/.mutt\x00LASTDIRFILE=/home/username/.lastpwd-geany\x00LOGNAME=username\...\x00\x00'
  </code></pre>
  
  <p>However run I make a ctypes variable out of it, it truncates the information:</p>
  
  <pre><code>ctypes.c_wchar_p(lpEnvironment)
  c_wchar_p(u'XAUTHORITY=/home/username/.Xauthority')
  </code></pre>
  
  <p>How can I pass the lpEnvironment information correctly?</p>