当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用ASP读取Windows标准INI格式文件

ASP
VPN技术详解(下)
微软Page Counter 组件参考(一)
微软Page Counter 组件参考(二)
@ 指令参考之一 - @CODEPAGE
@ 指令参考之二 - @ENABLESESSIONSTATE
@ 指令参考之三 - @LANGUAGE
@ 指令参考之四 - @LCID
@ 指令参考之五 - @TRANSACTION
SQL数据操作基础(初级) 1
SQL数据操作基础(初级) 2
SQL数据操作基础(初级) 3
Response对象1
Response对象2
Response对象3
Response对象4
Response对象5
WSH简介
WSH实用讲座:第一讲 获取机器的网络属性配置
WSH实用讲座---第二讲 创建用户、目录和站点
WSH实用讲座---第三讲 创建邮箱

用ASP读取Windows标准INI格式文件


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 62 ::
收藏到网摘: n/a

  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 looking at some parts of TEST.ASP:


<!--#include virtual="/readini/inifile.inc"-->
For fairly obvious reasons, we need to include the tools in our page, of course we should fix the path the include file is stored it.

<%
     call IniFileLoad("physical=c:\boot.ini")
%>

Next, a call to IniFileLoad fetches the INI file into a dictionary object called IniFileDictionary. You can specify a physical path as listed above, or you could specify a virtual path such as "virtual=/readini/test.ini".


StrBuf = IniFileValue("boot loader|timeout")
StrBuf = IniFileValue("boot loader")

Finally, we need to ask for a value from the dictionary. You can specify an individual value by using the section name and value name separated by a vertical bar (sometimes referred to as a 'pipe') character. Alternately, we can request the entire content of a section by not specifying the value name. When the section is returned, the data is formatted as:

   Section name|Value name=Value Data~Section name|ValueName=Value Data

Note that each section/value/data triplet is separated by a tilde character.

Well, that's all there is to it! Happy programming!

Attachments:
This ZIP file contains an INC file with the utility routines, a test INI file, and an ASP file that demonstrates the tools usage.

http://www.4guysfromrolla.com/webtech/code/inifile.zip