Ich versuche seit 3 Tagen ein einfaches Tutorial nachzubauen. Aber es will einfach nicht funktionieren und ich komme einfach nicht weiter.
Public Class Form1
Public Const SaveFile As String = "C:\test.ini" 'Pfad + Dateiname
Public Const Section As String = "Meine Daten" 'Überschrift in INI [xxxx]
#Region "API"
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 String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
Private Declare Ansi Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
Public Shared Function INI_ReadValueFromFile(ByVal strSection As String, ByVal strKey As String, ByVal strDefault As String, ByVal strFile As String) As String
Dim strTemp As String = Space(1024), lLength As Integer
lLength = GetPrivateProfileString(strSection, strKey, strDefault, strTemp, strTemp.Length, strFile)
Return strTemp.Substring(0, lLength)
End Function
Public Shared Function INI_WriteValueToFile(ByVal strSection As String, ByVal strKey As String, ByVal strValue As String, ByVal strFile As String) As Boolean
Return Not (WritePrivateProfileString(strSection, strKey, strValue, strFile) = 0)
End Function
#End Region
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
INI_WriteValueToFile(Section, "erster Wert", TextBox1.Text, SaveFile)
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
TextBox1.Text = INI_ReadValueFromFile(Section, "erster Wert", "", SaveFile)
End Sub
End Class
VB zeigt keine Fehler an, aber es wird einfach keine Datei erstellt.
Woran kann das liegen?

Hilfe
Neues Thema
Antworten


Nach oben




