Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringW" _ (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, _ ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32 Private Declare Unicode Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal lpKeyName As Object, ByVal lpString As Object, _ ByVal lpFileName As String) As Integer ' Read a Main.ini file value ' expC1 File ' expC2 Section ' expC3 Key ' expC4 Default value ' Optional Public Function GetIni(ByVal tcIniPath As String, ByVal tcSectionName As String, _ ByVal tcKeyName As String, Optional ByVal tcDefaultValue As String = "") As String Dim lcData As String Dim lnResult As Integer Dim lcValue As String lcData = Space$(1024) lnResult = GetPrivateProfileString(tcSectionName, tcKeyName, tcDefaultValue, lcData, lcData.Length, tcIniPath) If lnResult > 0 Then lcValue = lcData.Substring(0, lnResult) Else lcValue = "" End If Return lcValue End Function ' Write a Main.ini file value ' expC1 File ' expC2 Section ' expC3 Key ' expC4 Value Public Sub WriteIni(ByVal tcIniPath As String, _ ByVal tcSectionName As String, ByVal tcKeyName As String, ByVal tcValue As String) WritePrivateProfileString(tcSectionName, tcKeyName, tcValue, tcIniPath) End Sub