From: Anders Eriksson on
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

From: Herfried K. Wagner [MVP] on
Anders --

Am 15.03.2010 15:58, schrieb Anders Eriksson:
> I'm converting an old VB6 program to VB.NET and I have a problem with
> the Win32 function GetProvateProfileSection

For a working implementation, take a look at this code sample:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/IniLib.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>