较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.
源代码在线查看: 操作ini文件的com.htm
操作INI文件的COM
href="操作INI文件的COM.files/putong_1t" rel=StyleSheet type=text/css>
width=717>
style="FONT-SIZE: 14px"> style="FONT-SIZE: 14px">操作INI文件的COM style="FONT-SIZE: 14px">
更新日期:2002-11-5 阅读次数:747
这个是VB的代码,自己新建一个ActiveX
DLL,然后改变工程名称和类名称,然后在类中输入如下内容即可。'//////////////////////////////'中文名称:INI文件操作类'英文名称:Blood_INI
Class'作者:Blood'制作时间:2002.2.8'版本:1.0'版权所有 Blood
2002-2003'//////////////////////////////'申明变量Private
strAppName As String 'INI小节名称Private strKeyName As String
'INI项目名Private strValueStr As String 'INI的项目值Private strFileName
As String 'INI文件名'申明操作INI文件的APIPrivate 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 LongPrivate Declare Function
WritePrivateProfileString Lib "kernel32" Alias
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpString As String, ByVal lpFileName As String) As
Long'////////////////////'开始定义函数'////////////////////'定义写INI文件的函数Public
Function WriteINI() As Long'通过API将值写入INI文件WriteINI =
WritePrivateProfileString(strAppName, strKeyName, strValueStr,
strFileName)End Function'定义读INI文件的函数Public Function
GetINI() As StringConst STRING_SIZE = 255 '指定字符串长度Dim lngLength As
Long '定义API函数返回的长度Dim strDefault As String * STRING_SIZE
'定义在没有找到指定的项目时返回的默认值Dim strReturn As String * STRING_SIZE
'定义一个字符串缓冲区'通过API函数取得INI文件的内容lngLength =
GetPrivateProfileString(strAppName, strKeyName, strDefault, strReturn,
STRING_SIZE, strFileName)'通过判断API函数返回的长度来确定返回的值If (lngLength =
0) ThenGetINI = strValueStrElseGetINI = Mid(strReturn, 1,
lngLength)End IfEnd
Function'////////////////////'定义函数结束'////////////////////'////////////////////'开始定义属性'////////////////////'取得INI文件的名称Public
Property Let FileName(ByVal strFile As String)strFileName =
strFileEnd Property'取得项目值Public Property Let
ValueStr(ByVal strValue As String)strValueStr = strValueEnd
Property'取得项目名称Public Property Let KeyName(ByVal strKey As
String)strKeyName = strKeyEnd Property'取得小节名称Public
Property Let AppName(ByVal strApp As String)strAppName = strAppEnd
Property'////////////////////'结束定义属性'////////////////////
原作者:blood来 源:开发者俱乐部
width=717>