Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) 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 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 Sub Form_Load()
Open "C:\aa.ini" For Output As #1
Print #1, "文件内容"
Close #1
End Sub
Private Sub Label1_Click()
On Error GoTo Errhandle
ShellExecute Me.hwnd, "open", "www.sohu.com", vbNullString, vbNullString, 1
Exit Sub
Errhandle:
MsgBox Err.Description & "!", vbInformation
End Sub
'写INI文件
Private Sub Command1_Click()
Dim Counter As Long
For Counter = 1 To 4
Call WriteToIni(App.Path & "\Options.ini", "Test", "Name" & Counter, "Value" & Counter)
Next Counter
End Sub
'读INI文件
Private Sub Command2_Click()
Dim Counter As Long
Dim Value(3) As String
For Counter = 1 To 4
Value(Counter - 1) = ReadFromIni(App.Path & "\Options.ini", "Test", "Name" & Counter)
Next Counter
End Sub