Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
cINIFile.cls
Package: IE_VB.rar [view]
Upload User: davilee3
Upload Date: 2015-04-22
Package Size: 986k
Code Size: 5k
Category:
Browser Client
Development Platform:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "cINIFile"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- '---------------------------------------------------------------------------------------
- ' Module : cINIFile
- ' DateTime : 2005-3-19 20:17
- ' Author : Lingll
- ' Purpose :
- '---------------------------------------------------------------------------------------
- '2005-3-19 添加函数ReadSection,ReadSection2,ReadInt
- '8/5/2005 :strconv 增加使用了 LocaleID参数
- Option Explicit
- '确保strconv能正确转换
- Private Const LocaleID_SC As Long = 2052& '简中
- Private Const LocaleID_CurUse As Long = LocaleID_SC
- Private Declare Function GetPrivateProfileSection Lib "kernel32.dll" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As Long, ByVal nSize As Long, ByVal lpFileName As String) As Long
- Private Declare Function GetPrivateProfileInt Lib "kernel32.dll" 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 Long, 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 WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
- Public IniFile As String
- Public bffSize As Long
- Public Function ReadInt(SectionName$, KeyName$, Optional nDefault& = 0) As Long
- ReadInt = GetPrivateProfileInt(SectionName, KeyName, nDefault, IniFile)
- End Function
- Public Function ReadSection(SectionName$) As String
- Dim tBff() As Byte
- Dim tLen As Long
- tLen = FileLen(IniFile)
- If tLen > 0 Then
- ReDim tBff(0 To tLen - 1)
- tLen = GetPrivateProfileSection(SectionName, VarPtr(tBff(0)), tLen, IniFile)
- If tLen > 1 Then
- ReDim Preserve tBff(0 To tLen - 2)
- ReadSection = Replace$(StrConv(tBff, vbUnicode, LocaleID_CurUse), vbNullChar, vbNewLine)
- End If
- End If
- End Function
- Public Function ReadSection2(SectionName$, ptArr&, nSize&) As Long
- ReadSection2 = GetPrivateProfileSection(SectionName, ptArr, nSize, IniFile)
- End Function
- Public Function ReadKey(SectionName As String, _
- KeyName As String, Optional DefaultVal As String = vbNullString, _
- Optional IniName As String = vbNullString) As String
- Dim tBff() As Byte
- ' Dim tmpPos As Integer
- Dim tBffLen&, tIniFile$
- If LenB(IniName) <> 0 Then
- tIniFile = IniName
- Else
- tIniFile = IniFile
- End If
- ReDim tBff(0 To bffSize - 1)
- tBffLen = GetPrivateProfileString(SectionName, KeyName, _
- DefaultVal, VarPtr(tBff(0)), bffSize, tIniFile)
- If tBffLen > 0 Then
- ReDim Preserve tBff(0 To tBffLen - 1)
- ReadKey = StrConv(tBff, vbUnicode, LocaleID_CurUse)
- Else
- ReadKey = vbNullString '""
- End If
- End Function
- Public Function WriteKey(SectionName As String, KeyName As String, _
- nKey As String, Optional IniName As String = vbNullString) As Boolean
- Dim rtn&
- Dim tIniFile$
- If LenB(IniName) <> 0 Then
- tIniFile = IniName
- Else
- tIniFile = IniFile
- End If
- rtn = WritePrivateProfileString(SectionName, _
- KeyName, nKey, tIniFile)
- If rtn <> 0 Then
- WriteKey = True
- Else
- WriteKey = False
- End If
- End Function
- Public Function DeleteKey(SectionName As String, KeyName As String, _
- Optional IniName As String = vbNullString) As Boolean
- Dim rtn&
- Dim tIniFile$
- If LenB(IniName) <> 0 Then
- tIniFile = IniName
- Else
- tIniFile = IniFile
- End If
- rtn = WritePrivateProfileString(SectionName, _
- KeyName, 0&, tIniFile)
- If rtn <> 0 Then
- DeleteKey = True
- Else
- DeleteKey = False
- End If
- End Function
- Public Function DeleteSection(SectionName As String, _
- Optional IniName As String = vbNullString) As Boolean
- Dim rtn&
- Dim tIniFile$
- If LenB(IniName) <> 0 Then
- tIniFile = IniName
- Else
- tIniFile = IniFile
- End If
- rtn = WritePrivateProfileString(SectionName, _
- 0&, 0&, tIniFile)
- If rtn <> 0 Then
- DeleteSection = True
- Else
- DeleteSection = False
- End If
- End Function
- Private Sub Class_Initialize()
- IniFile = vbNullString '""
- bffSize = &H400& ' 256
- End Sub