用ASP读INI配置文件的函数

2016-01-29 18:57 35 1 收藏

用ASP读INI配置文件的函数,用ASP读INI配置文件的函数

【 tulaoshi.com - ASP 】

 

选择自 mind_1220 的 Blog

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

要求: 
能够读取按照  INI文件的Section和Key来读出相应的Value。 
比如一个配置文件   
SMSVote.ini 
--------------------------------- 
[SMSVote] 
Server=(local) 
DB=SMSVote 
User=sa 
PassWord=123 
[DB2Vote] 
Server=192.168.0.1 
DB=DB2 
User=sa 
PassWord= 
--------------------------------- 
 
 
主体程序(方法)  : 
 
inifile.asp 
----------------------------------------------- 
<% 
set  IniFileDictionary  =  CreateObject("Scripting.Dictionary") 
 
Sub  IniFileLoad(ByVal  FilSpc) 
   IniFileDictionary.RemoveAll 
   FilSpc  =  lcase(FilSpc) 
   if  left(FilSpc,  1)  =  "p"  then 
       'Physical  path 
       PhyPth  =  mid(FilSpc,  instr(FilSpc,  "=")  +  1) 
   else 
       'Virtual  path 
       PhyPth  =  Server.MapPath(mid(FilSpc,  instr(FilSpc,  "=")  +  1)) 
   end  if 
 
   set  FilSys  =  CreateObject("Scripting.FileSystemObject") 
   set  IniFil  =  FilSys.OpenTextFile(PhyPth,  1) 
   do  while  not  IniFil.AtEndOfStream 
       StrBuf  =  IniFil.ReadLine 
       if  StrBuf  <  ""  then 
           'There  is  data  on  this  line 
           if  left(StrBuf,  1)  <  ";"  then 
               'It's  not  a  comment 
               if  left(StrBuf,  1)  =  "["  then 
                   'It's  a  section  header 
                   HdrBuf  =  mid(StrBuf,  2,  len(StrBuf)  -  2) 
               else 
                   'It's  a  value 
                   StrPtr  =  instr(StrBuf,  "=") 
                   AltBuf  =  lcase(HdrBuf  &  "  ¦"  &  left(StrBuf,  StrPtr  -  1)) 
                   do  while  IniFileDictionary.Exists(AltBuf) 
                       AltBuf  =  AltBuf  &  "_" 
                   loop 
                   IniF

来源:https://www.tulaoshi.com/n/20160129/1507912.html

延伸阅读
标签: 服务器
Nginx 配置文件解析 cycle = ngx_init_cycle(&init_cycle): 1、在内存池中分配一个ngx_cycle_t变量,并初始化它的各个成员。 2、调用core类型的create_conf,实际只有一个ngx_core_module_create_conf函数----初始化ngx_core_conf_t结构(存放core_module支持的指令),保存在ngx_cycle-conf_ctx数组中。可以说,此时,ngx_c...
标签: ASP
  Have you needed to get information dynamically from Standard Formatted Windows INI files? Here's a set of tools to help you with just that. In this tutorial, we are going to discuss specific actions. More details can be obtained by looking at the files supplied. Let's see how to implement the tools usage by l...
[SETUP]CpuVendor=SamsungCpuChip=S3C4510CpuEndian=LITTLEFlashVendor=SiliconStorageTechnologyFlashChip=SST39LF/VF160RamAddress=0x00400000FlashAddress=0x00000000FlashWidth=16FlashChipsPerSector=1LittleEndian=1Sim1=SYSCFG:$E7FFFF90       \Sim2=EXTDBWTH:003002   \Sim3=ROMCON0:000060&...
标签: 电脑入门
对于普通的不依赖于外置程序目录结构的注册表项目,可以用常规方法将修改项写成REG文件(可以直接从XP系统中导出,然后在其基础上修)。在外置程序目录下有个RegDoc.cmd,这个文件是毛桃用来注册外置程序文档关联的(就是改注册表),可以用记事本打开它,加入一行: 则PE加载外部配置时它会自动导入。 这是最简单的改注册表的方法。但是如果要修...
本例子为读取配置文件,一般用作读取参数 /*  * Created on 2004-9-21  *  * Java读取配置文件例子 */ package net.jspcn.test; import java.util.*; import java.io.*; /**  * @author whilvydy  * ...

经验教程

438

收藏

62
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部