| Private Declare Function GetPrivateProfileString Lib "kernel32" 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 Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String Dim Str As String = LSet(Str, 256) GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName) Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1) End Function Public Function WriteINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As Long WriteINI = WritePrivateProfileString(Section, AppName, lpDefault, FileName) End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim path As String path = Application.StartupPath + "\ccadd.ini" WriteINI("ccadd", "cserver", cserver.Text, path) WriteINI("ccadd", "cuser", cuser.Text, path) WriteINI("ccadd", "cpwd", cpwd.Text, path) MsgBox("代码管理系统设置已经成功!!!!") Catch ex As Exception MsgBox("错误!!!!") End Try End Sub
Private Sub config_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim path As String path = Application.StartupPath + "\ccadd.ini" cserver.Text = GetINI("ccadd", "cserver", "", path) cuser.Text = GetINI("ccadd", "cuser", "", path) cpwd.Text = GetINI("ccadd", "cpwd", "", path) aserver.Text = GetINI("ccadd", "aserver", "", path) auser.Text = GetINI("ccadd", "auser", "", path) apwd.Text = GetINI("ccadd", "apwd", "", path) fserver.Text = GetINI("ccadd", "fserver", "", path) fuser.Text = GetINI("ccadd", "fuser", "", path) fpwd.Text = GetINI("ccadd", "fpwd", "", path) fdir.Text = GetINI("ccadd", "fdir", "", path) tdir.Text = GetINI("ccadd", "tdir", "", path) sfile.Text = GetINI("ccadd", "sfile", "", path) files.Text = GetINI("ccadd", "files", "", path) sbegin.Text = GetINI("ccadd", "sbegin", "", path) sskip.Text = GetINI("ccadd", "sskip", "", path) send.Text = GetINI("ccadd", "send", "", path) sfilter.Text = GetINI("ccadd", "sfilter", "", path) sbfile.Text = GetINI("ccadd", "sbfile", "", path) srar.Text = GetINI("ccadd", "srar", "", path) smemo.Text = GetINI("ccadd", "smemo", "", path)
End Sub
|