' Collection of code snippets by Arne Vajhøj ' posted to eksperten.dk, usenet and other places (2002-now) Imports System Imports System.Text Public Class IniFileSupport Private Declare Ansi Function GetPrivateProfileString _ Lib "kernel32.dll" Alias "GetPrivateProfileStringA" _ (ByVal lpApplicationName As String, _ ByVal lpKeyName As String, ByVal lpDefault As String, _ ByVal lpReturnedString As System.Text.StringBuilder, _ ByVal nSize As Integer, ByVal lpFileName As String) _ As Integer Public Shared Function GetString(fnm As String, section As String, key As String) As String Dim sb As StringBuilder = New StringBuilder GetPrivateProfileString(section, key, "*", sb, 100, fnm) GetString = sb.ToString End Function End Class Module Main Sub Main() Console.WriteLine(IniFileSupport.GetString("C:\myclock.ini", "aa", "a")) End Sub End Module