Files
Renzo Lanza 747d4c746d LicenceManager 2.1b5:
- Pulsante Delete cancella il record ma rimane nella pagina Search
- Lettura file .ini adattata al lettore già presente nell'applicativo
- Rinominati i file di configurazione in LicenceManager (.ini/.lic)
- Rinominato il file d Log
- Percorso KeyGenerator nel file .ini 
- Proposta data di oggi di default in NewLicencePage 
- ComboBox per ProductLevel con 1,5,10
- ComboBox in ordine di numero
- Aggiunti "---ANY---" nelle comboBox di SearchKeyPage 
- SearchKey: Risultati di ricerca in ordine di numero
- Adattamento al valore restituito (0 o 1) da KeyGenerator
- Importazione AboutBox OmagCUT (DA SISTEMARE)
2019-03-06 15:33:16 +00:00

68 lines
2.5 KiB
VB.net

Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text
Public Class IniManager
#Region "METODO NON FUNZIONANTE"
<DllImport("kernel32")>
Public Shared Function GetPrivateProfileString(ByVal section As String, ByVal key As String,
ByVal def As String, ByVal retVal As StringBuilder,
ByVal size As Integer, ByVal filePath As String) As Integer
End Function
Public Function GetIniValue(section As String, key As String, filename As String, Optional defaultValue As String = "") As String
Dim sb As New StringBuilder(500)
If GetPrivateProfileString(section, key, defaultValue, sb, sb.Capacity, filename) > 0 Then
Return sb.ToString
Else
Return defaultValue
End If
End Function
#End Region
#Region "METODO FUNZIONANTE"
Public Function ReadIni() As String
Dim reader As StreamReader = My.Computer.FileSystem.OpenTextFileReader("C:\EgtData\LicenceManager\Config\LicenceManager.ini")
Dim a As String
Dim result As String = ""
Do
a = reader.ReadLine
If (a Is Nothing) Then Exit Do
Dim fileline As String = a.Trim()
If (fileline.StartsWith("[") And fileline.EndsWith("]")) Then Continue Do
'
' Code here
'
Dim index As Integer = fileline.IndexOf("=")
If (index < 0) Then Continue Do
Dim key As String = fileline.Substring(0, index).Trim()
' Dim ID As String = fileline.Substring(0, fileline.IndexOf(":"))
Dim value As String = fileline.Substring(index + 1).Trim()
' String comment = ""
index = value.IndexOf("'")
If (index > -1) Then
' ID = fileline.Substring(0, fileline.IndexOf(":"))
' comment = value.Substring(index).Trim()
value = value.Substring(0, index).Trim()
End If
result &= key & "=" & value & ";"
Loop Until a Is Nothing
' result.TrimEnd(";")
reader.Close()
Return result
End Function
#End Region
'Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
' Debug.WriteLine(GetIniValue("B_Empty_IndexList", "Count", My.Application.Info.DirectoryPath & "\WorldInfo.ini"))
' Debug.WriteLine(GetIniValue("B_Use_IndexList", "Count", My.Application.Info.DirectoryPath & "\WorldInfo.ini"))
'End Sub
End Class