writeprofilestring (kernel32)
Last changed: tl9@trustmarkins.com-24.14.70.138

.
Summary

VB.NET Signature:

    <DllImport("kernel32.dll")> _
    Private Shared Function WriteProfileString(ByVal lpAppName As String, _
    ByVal lpKeyName As String, _
    ByVal lpString As String) As Boolean
    End Function

C# Signature:

[DllImport("kernel32.dll")]
static extern bool WriteProfileString(string lpAppName, string lpKeyName,
   string lpString);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

VB.NET

    Public Function SetProfileString(ByVal filename As String, ByVal section As String, ByVal key As String, ByVal sValue As String) As Boolean
    Dim bRslt As Boolean
    If filename = "" Then
        bRslt = WriteProfileString(section, key, sValue)
    Else
        bRslt = WritePrivateProfileString(section, key, sValue, filename)
    End If
    Return bRslt
    End Function

    Public Function SetProfileString(ByVal section As String, ByVal key As String, ByVal sValue As String) As Boolean
    Return SetProfileString("", section, key, sValue)
    End Function

VB.NET C# (sample code)

    Public bool SetProfileString(string section, string key, string sValue)
    {
        WriteProfileString("", section, key, sValue);
    }

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!

Documentation