'----------------------------------------------------------------------------
'  EgalTech 2017-2017
'----------------------------------------------------------------------------
' File : IniFile.vb       Data : 08.05.24        Versione : 2.6e1
' Contenuto : Modulo IniFile per gestione lettura/scrittura da file INI.
'
'
'
' Modifiche : 08.05.24 ES Creazione modulo.
'
'
'----------------------------------------------------------------------------


Imports System.Collections.ObjectModel

Public Module IniFile

   Private m_sPath As String
   Public ReadOnly Property sPath As String
      Get
         Return m_sPath
      End Get
   End Property
   Friend Sub SetIniFile(sPath)
      m_sPath = sPath
   End Sub

   Public Function GetPluginPrivateProfileInt(IpAppName As String, IpKeyName As String, nDefault As Integer) As Integer
      Return GetPrivateProfileInt(IpAppName, IpKeyName, nDefault, m_sPath)
   End Function

   Public Function GetPluginPrivateProfileDouble(IpAppName As String, IpKeyName As String, dDefault As Double) As Double
      Return GetPrivateProfileDouble(IpAppName, IpKeyName, dDefault, m_sPath)
   End Function

   Public Function GetPluginPrivateProfileString(IpAppName As String, IpKeyName As String, IpDefault As String, ByRef IpString As String) As Integer
      Return GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_sPath)
   End Function

   'Public Function GetPrivateProfileLanguage(lpAppName As String, lpKeyName As String, lpFileName As String) As Language
   '   Dim sVal As String = String.Empty
   '   GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
   '   Dim sItems() As String = sVal.Split(",".ToCharArray)
   '   If sItems.Count() = 2 Then
   '      Return New Language(sItems(0), sItems(1))
   '   End If
   '   Return Nothing
   'End Function

   'Public Function GetMainPrivateProfileLanguage(lpAppName As String, lpKeyName As String) As Language
   '   Dim sVal As String = String.Empty
   '   GetMainPrivateProfileString(lpAppName, lpKeyName, "", sVal)
   '   Dim sItems() As String = sVal.Split(",".ToCharArray)
   '   If sItems.Count() = 2 Then
   '      Return New Language(sItems(0), sItems(1))
   '   End If
   '   Return Nothing
   'End Function

   Public Function WritePluginPrivateProfileString(IpAppName As String, IpKeyName As String, ByRef IpString As String) As Boolean
      Return WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_sPath)
   End Function

End Module
