怎样读取一个.ini文件?

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

怎样读取一个.ini文件?

  2021-03-17 我要评论
想了解怎样读取一个.ini文件?的相关内容吗,在本文为您仔细讲解的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:怎样何读读取取一一个个iinnii文文件件??,下面大家一起来学习吧。

<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]

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们