Note that both
GetPrivateProfileString
and
WritePrivateProfileString
Win APIs are very buggy and have been deprecated long time ago.
You see these functions where provided only for compatibility with 16-bit applications, which I'm fairly certain that you are not developing so you should really reconsider using that.
Beside the bugs you must realize that on each reading and/or writing you are accessing the file and that will just yield terrible performances when you do somewhat realistic number of readings and/or writings.
May I suggest you to instead use
my INI file library for VB.NET[
^]. For example here is how you can retireve the value of specified 'section' and its 'key':
Dim ini As New IniFile()
ini.Load(m_sIniFileName)
Dim sReturnValue As String = ini.Sections(section).Keys(key).Value
Dim iReturnValue As Integer
ini.Sections(section).Keys(key).TryParseValue(iReturnValue)
Let me know if you need any help with this.