GetPrivateProfileString Oddity

I just messed with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from .NET and came across something strange that I don't understand.

Let's start with this phrase:

    Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringW" ( _
    ByVal lpApplicationName As String, _
    ByVal lpKeyName As String, _
    ByVal lpDefault As String, _
    ByVal lpReturnedString() As Char, _
    ByVal nSize As Int32, _
    ByVal lpFileName As String) As Int32

If I pass lpApplicationName (section), no lpKeyName and no lpDefault, I have to get all the keys for this section, and really, I do: 50% of the time.

If the ini file has the name lpApplicationName starting from the first line, the buffer does not return anything. If lpApplicationName is specified in the second line of the file, it returns the expected values.

At first I decided to use the version of W and Unicode in the ad, but changing them does not seem to have an effect.

What am I missing?

+5
source share
2

, , , ( , ).

Windows API, , (, , ).

+9

. ini VS.NET, , (Duh) utf-8. . SaveAs ASCII .

. . .: -)

! - = Chris

+1

All Articles