当前位置: 代码网 > it编程>编程语言>其他编程 > 如何读取一个.ini文件?

如何读取一个.ini文件?

2024年05月15日 其他编程 我要评论
<object id="agobjorasession" runat="server" progid="oracleinprocserver.xorasession" scope="applic

<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

 

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]

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com