下面,我们用这个“注册表”类来写一个简单的“计数器”应用,代码如下:
pagecount.asp:
<!-- #Include File="registry_class_inc.asp" -->
<%
Dim Reg
Set Reg = New RegistryObject
Reg.Path = Server.MapPath("pagecount.xml")
Const BaseCount = 8000 '计数器基数
Dim Count
Count = Reg.ReadValue("Pagecount", "Common", "Count") '读取原有计数
If IsNumeric(Count) Then
Count = CLng(Count)
Else
Count = BaseCount
End If
If Count < BaseCount Then Count = BaseCount
Count = Count + 1
Reg.SaveValue "Pagecount", "Common", "Count", Count '保存新计数
Set Reg = Nothing
Response.Write("document.write ('您是第 " & Count & " 位来访者');") ' 显示计数
%>
test.htm:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>测试XML计数器</title>
</head>
<body>
<script language="javascript" src="pagecount.asp"></script>
</body>
</html>
相关文章:
给网站添加一个注册表 之 “类的设计” 给网站添加一个注册表 之 “类的实现”本文地址:http://com.8s8s.com/it/it8910.htm