⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iniclass.cls

📁 学生信息系统 采用VB作为程序设计语言 SQL SERVER2000为数据库
💻 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 = "IniClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

  Private strINI As String
  Private strSection As String
  Private strKey As String
  Private strValue As String
  'Windows 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

  Private Sub CreateIni(strDrv As String, strDir As String)
  ' Make a new ini file
  strINI = MakePath(strDrv, strDir)
  End Sub
  Public Sub SetSection(ByVal Section As String)
  strSection = Section
  End Sub
  Public Sub setKey(ByVal Key As String)
  strKey = Key
  End Sub
  Public Sub WriteIniKey(ByVal Value As String)
  ' Write to strINI
  strValue = Value
  WritePrivateProfileString strSection, strKey, strValue, strINI
  End Sub

  Public Function GetIniKey(ByVal strSection As String, ByVal strKey As String)
  Dim strTmp As String
  Dim lngRet As String
  Dim i As Integer
  Dim strTmp2 As String

  strTmp = String$(1024, Chr(32))
  lngRet = GetPrivateProfileString(strSection, strKey, "", strTmp, Len(strTmp), strINI)
  strTmp = Trim(strTmp)
strTmp2 = ""
  For i = 1 To Len(strTmp)
  If Asc(Mid(strTmp, i, 1)) <> 0 Then
  strTmp2 = strTmp2 + Mid(strTmp, i, 1)
  End If
  Next i
  strTmp = strTmp2

  GetIniKey = strTmp
  End Function

  Public Property Let INIFileName(ByVal New_IniPath As String)
  ' Sets the new ini path
  strINI = New_IniPath
  End Property

  Public Property Get INIFileName() As String
  ' Returns the current ini path
  INIFileName = strINI
  End Property

  '***************************************清除KeyWord"键"(Sub)********
  Public Function DelIniKey(ByVal SectionName As String, ByVal KeyWord As String)
  Dim RetVal As Integer
  RetVal = WritePrivateProfileString(SectionName, KeyWord, 0&, strINI)
  End Function

  '如果是清除section就少写一个Key多一个""。
  '**************************************清除 Section"段"(Sub)********
  Public Function DelIniSec(ByVal SectionName As String) '清除section
  Dim RetVal As Integer
  RetVal = WritePrivateProfileString(SectionName, 0&, "", strINI)
  End Function
Public Function WriteIniKeyEx(ByVal SectionName As String, ByVal Key As String, ByVal Value As String) As Long
WritePrivateProfileString SectionName, Key, Value, strINI
End Function


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -