title: VBA GetPrivateProfileString
body: <p>I want to read an INI File with <code>GetPrivateProfileString</code>.<br>
  The problem is that my string contains some characters that should not be there</p>
  
  <p><a href="https://i.stack.imgur.com/zpaOP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zpaOP.jpg" alt="Picture"></a></p>
  
  <p>I think that this issue is coming from <code>path = String(255,0)</code> but if I do not write this, my Excel program just stops working.</p>
  
  <p>Is there a way to bypass this problem or is something wrong with my code?</p>
  
  <p><strong>Sub</strong></p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim path as String,m2_path as string
  path = String(255, 0)
  m2_path = String(255, 0)
  
  nc = GetPrivateProfileString("PATH", "path1", "", path, 255, inipath)
  nc = GetPrivateProfileString("PATH", "path2", "", m2_path, 255, inipath)
  </code></pre>
  
  <p><strong>Function</strong></p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
               (ByVal lpApplicationName As String, _
                 ByVal lpKeyName As String, _
                 ByVal lpDefault As String, _
                 ByVal lpReturnedString As String, _
                 ByVal nSize As Long, _
                 ByVal lpFileName As String) As Long
  </code></pre>
  
  <p><strong>INI file</strong></p>
  
  <pre class="lang-none prettyprint-override"><code>[PATH]
  path1="G:\Arbeit\gen molding"
  ...
  </code></pre>