ini文件的读取
控件:TEXT 3 COMMAND 2
Private Sub Command2_Click()
Dim rs As String
Dim buff As String
Dim ret As Long
Public 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
'主窗口代码
'变量:success ret buff rs
'
'
'
****************************************************************************
Option Explicit
Private Sub Command1_Click()
Dim success As Long
Dim success As Long
dim success1 as long
dim success2 as long
Dim ret As Long
Dim buff As String
Dim rs As String
buff = String(255, 0)
Dim ret As Long
Dim buff As String
Dim rs As String
buff = String(255, 0)
success = WritePrivateProfileString("MyApp", "text1", Text1.Text, "c:\aa.ini")
success=WritePrivateProfileString("App", "text1", Text1.Text, "c:\aa.ini")
End Sub
Private Sub Command2_Click()
Dim rs As String
Dim buff As String
Dim ret As Long
buff = String(255, 0)
ret = GetPrivateProfileString("Myapp", "text1", "hello", buff, 256, "c:\aa.ini")
MsgBox buff
Shell buff, 1
End Sub
ret = GetPrivateProfileString("Myapp", "text1", "hello", buff, 256, "c:\aa.ini")
MsgBox buff
Shell buff, 1
End Sub
Private Sub form_load()
Dim ret As Long
Dim buff As String
Dim rs As String
buff = String(255, 0)
ret = GetPrivateProfileString("Myapp", "text1", "fx1", buff, 256, "c:\aa.ini")
Dim ret As Long
Dim buff As String
Dim rs As String
buff = String(255, 0)
ret = GetPrivateProfileString("Myapp", "text1", "fx1", buff, 256, "c:\aa.ini")
MsgBox buff
buff = String(255, 0)
ret = GetPrivateProfileString("app", "text2", "fx2", buff, 256, "c:\aa.ini")
Text2.Text = buff
buff = String(255, 0)
ret = GetPrivateProfileString("app2", "text3", "fx3", buff, 256, "c:\aa.ini")
Text3.Text = buff
End Sub
ret = GetPrivateProfileString("app", "text2", "fx2", buff, 256, "c:\aa.ini")
Text2.Text = buff
buff = String(255, 0)
ret = GetPrivateProfileString("app2", "text3", "fx3", buff, 256, "c:\aa.ini")
Text3.Text = buff
End Sub
*****************************************************************************
'标准模块中 代码
'API GetPrivateProfileString
' WritePrivateProfileString
'
'
****************************************************************************
Option Explicit
Public 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
Public 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