如何读取一个.ini文件?_编程10000问

<OBJECT ID="agobjOraSession" RUNAT="Server" PROGID="OracleInProcServer.XOraSession" SCOPE="Application">
</OBJECT>
<script LANGUAGE=VBScript RUNAT=Server>
Const CONST_FL_NAME = "\GetAttributeCode.ini"
Const CONST_FL_FORREADING = 1
Const CONST_DB_SECTION = "[DB_CONNECTION]"Sub Application_OnStart
On Error Resume Next

  Dim objFs     
  Dim objTs         
  Dim strLineData     
  Dim flgSection     
  Dim strTempData 

  Application("Service") = ""
  Application("User") = ""
  strLineData = "" 
  strTempData = ""
  flgSection = False

  Set objFs = Server.CreateObject ("Scripting.FileSystemObject")
  Set objTs = objFs.OpenTextFile(Server.MapPath(CONST_FL_NAME),CONST_FL_FORREADING,False)
  If Err.Number <> 0 Then
    Err.Clear
     Set objTs = Nothing
    Set objFs = Nothing
    Exit Sub
  End If

While Not objTs.AtEndOfStream
    strLineData = objTs.ReadLine
   If Trim(strLineData) <> "" Then
        If flgSection = True And Mid(strLineData,1,1) = "[" And _
        Mid(strLineData,Len(strLineData),1) = "]" Then
       objTs.Close
         Set objTs = Nothing
       Set objFs = Nothing
       Exit Sub
      End If

      If strLineData = CONST_DB_SECTION Then
       flgSection = True
     End If<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

If flgSection = True Then
      If Mid(strLineData,1,7) = "Service" Then
        strTempData = Trim(Mid(strLineData,8,Len(strLineData)-7))
        If Mid(strTempData,1,1) = "=" Then
          strTempData = Trim(Mid(strTempData,2,Len(strTempData)-1))
          Application.Lock
           Application("Service") = Mid(strTempData,2,Len(strTempData)-2)
          Application.UnLock
       End If
    End If
    If Mid(strLineData,1,4) = "User" Then
        strTempData = Trim(Mid(strLineData,5,Len(strLineData)-4))
        If Mid(strTempData,1,1) = "=" Then
        strTempData = Trim(Mid(strTempData,2,Len(strTempData)-1))
        Application.Lock
        Application("User") = Mid(strTempData,2,Len(strTempData)-2)
        Application.UnLock
      End If
End If
End If
End If
Wend
objTs.Close
Set objTs = Nothing
Set objFs = Nothing
End Sub
</script>

 


 


[1]

时间: 2024-07-29 06:25:37

如何读取一个.ini文件?_编程10000问的相关文章

如何把Recordset转换成彩色的XML文件_编程10000问

<%@ codepage="65001" %> <!-- #INCLUDE FILE="ADOVBS.INC" --> <% Response.ContentType = "text/xml" ' 如果不在 adovbs.inc 里,则设置一个常量.  <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office&qu

如何显示一个文本文件?_编程10000问

 Write(StrING) WriteLine(StrING) WriteBlankLines(LINES)  <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 〈html〉 〈head〉 〈http-equiv="Content-Type" content="text/html; charset=gb2312"〉 〈title〉

如何通过表单创建一个Word?_编程10000问

docform.htm<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> <form action="doccreate.asp">姓名: <input type="text" name="Name" size="50" maxlength="100">

如何创建Word文件?_编程10000问

creatdoc.asp<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> <!DOCTYPE html PUBLIC "-//W3C/Dtd html 3.2 Final//EN"><head><title>星河影动之创建Word文件</title><META HTTP-EQUIV="Re

ASP问答集_编程10000问

问:为什么我的记录集的RecordCount值总是返回-1? 答:你应当使用这种模式来打开存取数据库的记录集:   rec.open strSQL,conn,1,1   其中的strSQL是操作数据库的SQL语句;conn是联接数据库的Connection 变量. 问:我在ASP脚本中写了很多的注释,这会不会影响服务器处理ASP文件的速度? 答:经国外技术人员测试,带有过多注释的ASP文件整体性能仅仅会下降0.1%,也就是说基本上不会影响到服务器的性能下降的. 问:我需不需要在每个ASP文件的开

如何实现无组件上传二进制文件?_编程10000问

<!--METADATA TYPE="typelib"      UUID="00000205-0000-0010-8000-00AA006D2EA4"    NAME="ADODB Type Library"--><%  Dim objStream  Set objStream = Server.CreateObject("ADODB.Stream")<?xml:namespace prefix =

如何一行行地读取文件?_编程10000问

dim input(30) <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> ' 定义一个数组,大小可随时更改.这里为了显示方便. file_path=Server.Mappath("index.html") Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f

如何把一个Excel文件放到ASP页面中去?_编程10000问

<%set xlApp = Server.CreateObject("Excel.Application")xlApp.Visible = false<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> ' 使服务端不出现Excel窗口.set myWorkbook = xlApp.Workbooks.Add ' 建立一个worksheet.set

如何计算下载一个文件需要多长时间?_编程10000问

<%Function DownloadTime(intFileSize, strModemType)Dim TimeInSeconds, ModemSpeed, strDownloadTime, AppendStringDim intYears, intWeeks, intDaysDim intHours, intMinutes, intSecondsintYears = 0intWeeks = 0intDays = 0intHours = 0intMinutes = 0intSeconds =