Asp中Global.asa的应用(-)

类别:Asp 点击:0 评论:0 推荐:

功能是读取发布目录下一个ini文件信息

<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



本文地址:http://com.8s8s.com/it/it9337.htm