?? mk_cls_inictrls.cls
字號:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsINI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'\____________________________________________________________________________________
' Dim myinifile As New cinifile
' '---指定訪問的ini文件
' If Len(App.Path) > 3 Then
' 'under disk root dir , eg: "c:\"
' myinifile.inifile = App.Path & "\setting.ini"
' Else
' myinifile.inifile = App.Path & "setting.ini"
' End If
' '---寫入ini文件
' myinifile.writefile "setting", "username", struser
' '---讀出ini文件的數據
' ' 注意,如果是字符串,則去掉末尾一個字符
' struser = Trim(myinifile.getfile("setting", "username"))
' struser = Left(struser, Len(struser) - 1)
'\____________________________________________________________________________________
Option Explicit
'private member that holds a reference to the path of our ini file
Private strini As String
'win api declares
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 Function makepath(ByVal strdrv As String, _
ByVal strdir As String) As String
'makes an ini file: guarantees a sub dir
Do While Right$(strdrv, 1) = "\"
strdrv = Left$(strdrv, Len(strdrv) - 1)
Loop
Do While Left$(strdir, 1) = "\"
strdir = Mid$(strdir, 2)
Loop
'return the path
makepath = strdrv & "\" & strdir
End Function
Public Sub createini(strdrv As String, strdir As String)
'make a new ini file
strini = makepath(strdrv, strdir)
End Sub
Public Sub writefile(strsection As String, _
strkey As String, _
strvalue As String)
'write to strini
writeprivateprofilestring strsection, _
strkey, strvalue, strini
End Sub
Public Function getfile(strsection As String, _
strkey As String) As String
Dim strtmp As String
Dim lngret As String
strtmp = String$(100, Chr(32))
lngret = getprivateprofilestring(strsection, _
strkey, "", strtmp, _
Len(strtmp), strini)
getfile = strtmp
End Function
Public Property Let inifile(ByVal new_inipath As String)
'sets the new ini path
strini = new_inipath
End Property
Public Property Get inifile() As String
'returns the current ini path
inifile = strini
End Property
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -