mirror of
https://e.coding.net/circlecloud/VBFunctionBas.git
synced 2024-12-29 08:18:46 +00:00
132 lines
5.8 KiB
QBasic
132 lines
5.8 KiB
QBasic
|
Attribute VB_Name = "Config"
|
|||
|
'#######################################<23>û<EFBFBD><C3BB>ؼ<EFBFBD>˵<EFBFBD><CBB5>#########################################
|
|||
|
|
|||
|
'<27><><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ģ<EFBFBD><C4A3>
|
|||
|
|
|||
|
'<27><><EFBFBD><EFBFBD>:<3A><>ȡд<C8A1><D0B4>INI<4E><49><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:2014<31><34>5<EFBFBD><35>7<EFBFBD><37>
|
|||
|
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
'<27><>λ:<3A>Ϻ<EFBFBD><CFBA>ж<EFBFBD><D0B6><EFBFBD>ˮ<EFBFBD>繤<EFBFBD>̰<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>˾
|
|||
|
|
|||
|
''====================================<3D>ؼ<EFBFBD>ʹ<EFBFBD><CAB9>˵<EFBFBD><CBB5>=======================================
|
|||
|
|
|||
|
'<27>÷<EFBFBD>: <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>iniFileName="<22>ļ<EFBFBD><C4BC><EFBFBD>" <20><><EFBFBD><EFBFBD>Ҫ <20><>ini<6E><69>
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD>ֵ<EFBFBD><D6B5>iniFileName<6D>Ϳ<EFBFBD><CDBF><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱд<CAB1>벻ͬ<EBB2BB><CDAC>ini<6E>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4>ڣ<EFBFBD><DAA3><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DelInikey (<28><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>)
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DelIniSec (<28><><EFBFBD><EFBFBD>)
|
|||
|
'д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SetIniN (<28><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>, д<><D0B4>ֵ)
|
|||
|
'<27><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>GetIniN (<28><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>, Ĭ<><C4AC>ֵ)
|
|||
|
'д<><D0B4><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>SetIniS (<28><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>, д<><D0B4>ֵ)
|
|||
|
'<27><>ȡ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>GetIniS (<28><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>, Ĭ<><C4AC>ֵ)
|
|||
|
|
|||
|
'#######################################ģ<><C4A3>˵<EFBFBD><CBB5>#########################################
|
|||
|
|
|||
|
Option Explicit
|
|||
|
''================================INI<4E>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>=========================================
|
|||
|
Public iniFileName As String
|
|||
|
Public DirMode As Boolean
|
|||
|
Public DirPath As String
|
|||
|
Public ALLDirPath As String
|
|||
|
Public ReSetDirPath As Boolean
|
|||
|
Private FileDir As String
|
|||
|
Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, 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 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
|
|||
|
|
|||
|
'========================================INI<4E><49><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ģ<EFBFBD><C4A3>=====================================================
|
|||
|
|
|||
|
'****************************************<2A><>ȡIni<6E>ַ<EFBFBD><D6B7><EFBFBD>ֵ(Function)******************************************
|
|||
|
Public Function GetIniS(ByVal SectionName As String, ByVal KeyWord As String, Optional ByVal DefString As String) As String
|
|||
|
Dim ResultString As String * 144, Temp As Integer
|
|||
|
Dim S As String, i As Integer
|
|||
|
Temp% = GetPrivateProfileString(SectionName, KeyWord, "", ResultString, 144, AppProFileName(iniFileName))
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ʵ<EFBFBD>ֵ
|
|||
|
If Temp% > 0 Then '<27>ؼ<EFBFBD><D8BC>ʵ<EFBFBD>ֵ<EFBFBD><D6B5>Ϊ<EFBFBD><CEAA>
|
|||
|
' s = Mid$(ResultString, 1, Temp%)
|
|||
|
For i = 1 To 144
|
|||
|
If Asc(Mid$(ResultString, i, 1)) = 0 Then
|
|||
|
Exit For
|
|||
|
Else
|
|||
|
S = S & Mid$(ResultString, i, 1)
|
|||
|
End If
|
|||
|
Next
|
|||
|
Else
|
|||
|
If DefString <> vbNullString Then
|
|||
|
Temp% = WritePrivateProfileString(SectionName, KeyWord, DefString, AppProFileName(iniFileName))
|
|||
|
'<27><>ȱʡֵд<D6B5><D0B4>INI<4E>ļ<EFBFBD>
|
|||
|
S = DefString
|
|||
|
Else
|
|||
|
S = ""
|
|||
|
End If
|
|||
|
End If
|
|||
|
GetIniS = S
|
|||
|
End Function
|
|||
|
|
|||
|
'**************************************<2A><>ȡIni<6E><69>ֵ(Function)***************************************************
|
|||
|
Public Function GetIniN(ByVal SectionName As String, ByVal KeyWord As String, ByVal DefValue As Long) As Integer
|
|||
|
Dim D As Long, S As String
|
|||
|
D = DefValue
|
|||
|
GetIniN = GetPrivateProfileInt(SectionName, KeyWord, DefValue, AppProFileName(iniFileName))
|
|||
|
If D <> DefValue Then
|
|||
|
S = "" & D
|
|||
|
D = WritePrivateProfileString(SectionName, KeyWord, S, AppProFileName(iniFileName))
|
|||
|
End If
|
|||
|
End Function
|
|||
|
|
|||
|
'***************************************д<><D0B4><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ֵ(Sub)**************************************************
|
|||
|
Public Sub SetIniS(ByVal SectionName As String, ByVal KeyWord As String, ByVal ValStr As String)
|
|||
|
Dim res%
|
|||
|
res% = WritePrivateProfileString(SectionName, KeyWord, ValStr, AppProFileName(iniFileName))
|
|||
|
End Sub
|
|||
|
|
|||
|
'****************************************д<><D0B4><EFBFBD><EFBFBD>ֵ(Sub)******************************************************
|
|||
|
Public Sub SetIniN(ByVal SectionName As String, ByVal KeyWord As String, ByVal ValInt As Long)
|
|||
|
Dim res%, S$
|
|||
|
S$ = Str$(ValInt)
|
|||
|
res% = WritePrivateProfileString(SectionName, KeyWord, S$, AppProFileName(iniFileName))
|
|||
|
End Sub
|
|||
|
|
|||
|
'***************************************<2A><><EFBFBD><EFBFBD>KeyWord"<22><>"(Sub)*************************************************
|
|||
|
Public Sub DelIniKey(ByVal SectionName As String, ByVal KeyWord As String)
|
|||
|
Dim retval As Integer
|
|||
|
retval = WritePrivateProfileString(SectionName, KeyWord, 0&, AppProFileName(iniFileName))
|
|||
|
End Sub
|
|||
|
|
|||
|
'**************************************<2A><><EFBFBD><EFBFBD> Section"<22><>"(Sub)***********************************************
|
|||
|
Public Sub DelIniSec(ByVal SectionName As String) '<27><><EFBFBD><EFBFBD>section
|
|||
|
Dim retval As Integer
|
|||
|
retval = WritePrivateProfileString(SectionName, 0&, "", AppProFileName(iniFileName))
|
|||
|
End Sub
|
|||
|
|
|||
|
'*************************************<2A><><EFBFBD><EFBFBD>Ini<6E>ļ<EFBFBD><C4BC><EFBFBD>(Function)***************************************************
|
|||
|
'<27><><EFBFBD><EFBFBD>ini<6E>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
Public Function AppProFileName(iniFileName)
|
|||
|
If InStr(1, iniFileName, ":") <> 0 Then
|
|||
|
AppProFileName = iniFileName
|
|||
|
Else
|
|||
|
If Right(App.Path, 1) <> "\" Then AppProFileName = App.Path & "\"
|
|||
|
ALLDirPath = AppProFileName
|
|||
|
If DirMode Then
|
|||
|
AppProFileName = AppProFileName & DirPath & "\"
|
|||
|
ALLDirPath = AppProFileName
|
|||
|
If ReSetDirPath Then
|
|||
|
FileDir = Dir(ALLDirPath & "\*")
|
|||
|
While FileDir <> ""
|
|||
|
Kill ALLDirPath & "\" & FileDir
|
|||
|
FileDir = Dir(ALLDirPath & "\*")
|
|||
|
Wend
|
|||
|
ReSetDirPath = False
|
|||
|
End If
|
|||
|
If Dir(AppProFileName, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly) = "" Then
|
|||
|
MkDir AppProFileName
|
|||
|
End If
|
|||
|
End If
|
|||
|
AppProFileName = AppProFileName & iniFileName & ".ini"
|
|||
|
End If
|
|||
|
End Function
|
|||
|
'========================================INI<4E><49><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ģ<EFBFBD><C4A3>=====================================================
|