Although after entering the Win95, the general read-write INI file was replaced by the read and write registry, but we can still read and write the INI file through the Win31 traditional way, to save the current program related settings, and the next time the program is executed to read back. It is currently recommended that GetSetting SaveSetting be used in registry, not in the current way. The setup of the stored program
' Please put 3 textbox in form, a Commandbox
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 Sub Command1_Click ()
Dim success as Long
Success = WritePrivateProfileString ("MyApp", "Text1", Text1.Text, "C:\aa.ini")
' Three one section Name
' Two items in. ini
' The contents of the three three items
' The name of the three four. ini file
Success = WritePrivateProfileString ("MyApp", "Text2", Text2.text, "C:\aa.ini")
Success = WritePrivateProfileString ("MyApp2", "Text3", Text3.text, "C:\aa.ini")
End Sub
Private Sub Form_Load ()
DIM ret as Long
Dim Buff as String
Buff = String (255, 0)
ret = getprivateprofilestring ("Myapp", "Text1", "Text1", Buff, 256, "C:\aa.ini")
' If there is no text1 in the. ini MyApp, the value of three three is used
Text1.Text = Buff
Buff = String (255, 0)
ret = getprivateprofilestring ("Myapp", "Text2", "Text2", Buff, 256, "C:\aa.ini")
Text2.text = Buff
Buff = String (255, 0)
ret = getprivateprofilestring ("Myapp2", "Text3", "Text3", Buff, 256, "C:\aa.ini")
Text3.text = Buff
End Sub