GetPrivateProfileSection

  • Thread starter Thread starter Anders Eriksson
  • Start date Start date
A

Anders Eriksson

Hello,

I'm converting an old VB6 program to VB.NET and I have a problem with the
Win32 function GetProvateProfileSection

I use this code:

Dim pBuffer As IntPtr
pBuffer = Marshal.AllocCoTaskMem(MaxIniBuffer)
bytesRead = GetPrivateProfileSection(m_sSection, pBuffer, MaxIniBuffer,
m_sPath)
If (bytesRead > 0) Then
xbuf = Marshal.PtrToStringAnsi(pBuffer,
bytesRead).ToString()
xlen = xbuf.Length
end if

The problem is that GetPrivateProfileSection returns a null separated list
of all keys that are in the section. bytesRead is correct.

But when I convert it to a string then I only get up till the first \0

The program expects to get a string which includes the null '\0'

// Anders
 
Back
Top