ERFORDERLICHE
OBJEKTE
4 Commandbuttons (Command1,Command2,Command3,Command4)
FORM-CODE
Dim Dateiname As String
Private Declare Function GetPrivateProfileString Lib "Kernel32" _
Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As _
String, ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "Kernel32" _
Alias "WritePrivateProfileStringA" (ByVal lpApplicationName _
As String, ByVal lpKeyName As Any, ByVal lpString As Any, _
ByVal lpFileName As String) As Long
Private Function WriteINI(Dateiname As String, DieSektion As String, _
DerEintrag As String, Wert As String) As Long
WriteINI = WritePrivateProfileString(DieSektion, DerEintrag, _
Wert, Dateiname)
End Function
Private Function GetINIString(Dateiname As String, _
DieSektion As String, DerEintrag As String) As String
Temp$ = String(255, 0)
x = GetPrivateProfileString(DieSektion, DerEintrag, "", _
Temp$, 255, Dateiname)
Temp$ = Left$(Temp$, x)
GetINIString = Temp$
End Function
Private Sub Command1_Click()
x = WriteINI(Dateiname$, "SEKTION", "EINTRAG", "0815")
End Sub
Private Sub Command2_Click()
s = GetINIString(Dateiname$, "Sektion", "Eintrag")
MsgBox s
End Sub
Private Sub Command3_Click()
x = WritePrivateProfileString("Sektion", "Eintrag", ByVal 0&, _
Dateiname$)
End Sub
Private Sub Command4_Click()
x = WritePrivateProfileString("Sektion", ByVal 0&, ByVal 0&, _
Dateiname$)
End Sub
Private Sub Form_Load()
Dateiname$ = App.Path
If Right(Dateiname$, 1) <> "\" Then Dateiname$ = Dateiname$ & "\"
Dateiname$ = Dateiname$ & "test.ini"
End Sub
|