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 cmdOK_Click()
Dim success As Long
success = WritePrivateProfileString("帐号资料", "ID", UserName.Text, "sgyscfg.ini")
success = WritePrivateProfileString("帐号资料", "PW", PassWord.Text, "sgyscfg.ini")
End Sub
Private Sub Form_Load()
Dim ret As Long
Dim buff As String
buff = String(255, 0)
ret = GetPrivateProfileString("帐号资料", "UserName", "", buff, 256, "sgyscfg.ini")
UserName.Text = buff
buff = String(255, 0)
ret = GetPrivateProfileString("帐号资料", "PassWord", "", buff, 256, "sgyscfg.ini")
PassWord.Text = buff
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 Declare Function GetCurrentDirectory Lib "Kernel32" _
Alias "GetCurrentDirectoryA" (ByVal nBuffSize As Long, _
ByVal lpPathBuff As String) As Long
Private Sub Command1_Click()
Dim szPathBuff As String
Dim szPathIniName As String
Dim Length As Long
Dim b As Boolean
szPathBuff = String(256, 0)
szPathIniName = "sgyscfg.ini"
Length = GetCurrentDirectory(256, szPathBuff)
If Mid(szPathBuff, Length, 1) <> "\" Then
szPathIniName = "\" & szPathIniName
End If
szPathIniName = Mid(szPathBuff, 1, Length) & szPathIniName
b = WritePrivateProfileString("帐号资料", "UserName", Text1.Text, szPathIniName)
b = WritePrivateProfileString("帐号资料", "PassWord", Text2.Text, szPathIniName)
End Sub
Private Sub Command2_Click()
Dim szPathBuff As String
Dim szPathIniName As String
Dim szBuff As String
Dim Length As Long
Dim l As Long
szPathBuff = String(256, 0)
szBuff = String(256, 0)
szPathIniName = "sgyscfg.ini"
Length = GetCurrentDirectory(256, szPathBuff)
If Mid(szPathBuff, Length, 1) <> "\" Then
szPathIniName = "\" & szPathIniName
End If
szPathIniName = Mid(szPathBuff, 1, Length) & szPathIniName
l = GetPrivateProfileString("帐号资料", "UserName", "", szBuff, 256, szPathIniName)
Text1.Text = szBuff
szBuff = String(256, 0)
l = GetPrivateProfileString("帐号资料", "PassWord", "", szBuff, 256, szPathIniName)
Text2.Text = szBuff
End Sub
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 Declare Function GetModuleFileName Lib "Kernel32" _
Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpPathBuff As String, _
ByVal nBuffSize As Long) As Long
Private Sub Command1_Click()
Dim szPathBuff As String
Dim szPathIniName As String
Dim Length As Long
Dim b As Boolean
Dim i As Integer, j As Integer
szPathBuff = String(256, 0)
szPathIniName = "sgyscfg.ini"
Length = GetModuleFileName(App.hInstance, szPathBuff, 256)
j = Length
For i = 1 To Length
If Mid(szPathBuff, j, 1) = "\" Then
Exit For
End If
j = j - 1
Next i
szPathIniName = Mid(szPathBuff, 1, j) & szPathIniName
b = WritePrivateProfileString("帐号资料", "UserName", Text1.Text, szPathIniName)
b = WritePrivateProfileString("帐号资料", "PassWord", Text2.Text, szPathIniName)
End Sub
Private Sub Command2_Click()
Dim szPathBuff As String
Dim szPathIniName As String
Dim szBuff As String
Dim Length As Long
Dim l As Long
Dim i As Integer, j As Integer
szPathBuff = String(256, 0)
szBuff = String(256, 0)
szPathIniName = "sgyscfg.ini"
Length = GetModuleFileName(App.hInstance, szPathBuff, 256)
j = Length
For i = 1 To Length
If Mid(szPathBuff, j, 1) = "\" Then
Exit For
End If
j = j - 1
Next i
szPathIniName = Mid(szPathBuff, 1, j) & szPathIniName
l = GetPrivateProfileString("帐号资料", "UserName", "", szBuff, 256, szPathIniName)
Text1.Text = szBuff
szBuff = String(256, 0)
l = GetPrivateProfileString("帐号资料", "PassWord", "", szBuff, 256, szPathIniName)
Text2.Text = szBuff
End Sub
Private Sub Form_Load()
Dim ret As Long
Dim buff As String
buff = String(255, 0)
ret = GetPrivateProfileString("帐号资料", "UserName", "", buff, 256, "sgyscfg.ini")
UserName.Text = buff
buff = String(255, 0)
ret = GetPrivateProfileString("帐号资料", "PassWord", "", buff, 256, "sgyscfg.ini")