590
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
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
Sub SetIniS(ByVal SectionName As String, ByVal KeyWord As String, ByVal ValStr As String)
Dim res%
res% = WritePrivateProfileString(SectionName, KeyWord, ValStr, App.Path & "\Profile.ini")
End Sub
Function GetIniS(ByVal SectionName As String, ByVal KeyWord As String, ByVal DefString As String) As String
Dim llLen As Long
Dim ResultString As String
ResultString = Space(100)
llLen = GetPrivateProfileString(SectionName, KeyWord, DefString, ResultString, 100, App.Path & "\Profile.ini")
GetIniS = Mid(ResultString, 1, llLen)
End Function
Private Sub Command1_Click()
Call SetIniS("section1", "keyword1", Text1.Text)
Call SetIniS("section1", "keyword2", Text2.Text)
End Sub
Private Sub Command2_Click()
MsgBox "测试版尚未开发"
End Sub
Private Sub Command3_Click()
Dim X
X = MsgBox("确定要删除吗", vbYesNo, "删除确认")
If X = vbYes Then
Call SetIniS("section1", "driverletter" + Text5.Text, "False")
End If
driverletter = Text5.Text
Shell "cmd /c rd " & driverletter & ":\ttc..\"
MsgBox "成功执行命令"
End Sub
Private Sub Command4_Click()
Form2.Visible = True
Form5.Visible = False
End Sub
Private Sub Command5_Click()
Text4.Text = GetIniS("section1", "dataname", DefString)
End Sub
Private Sub Form_Load()
Text4.Text = GetIniS("section1", "dataname", DefString)
Command1.Enabled = False
End Sub
Private Sub Text3_Change()
If Text3.Text = GetIniS("section1", "keyword2", DefString) Then
Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub
Private Sub Text4_Change()
Call SetIniS("section1", "dataname", Text4.Text)
End Sub