% function counts(counterfile) dim objfso,objts application.lock '锁定对象 set objfso=server.createobject("scripting.filesystemobject") set objts=objfso.opentextfile(server.mappath(counterfile),1,true) if not objts.atendofstream then '检查是否到达文件结尾 counts=clng(objts.readline) end if counts=counts+1 objts.close set objts=objfso.opentextfile(server.mappath(counterfile),2,true) objts.writeline(counts) objts.close application.unlock '解除锁定 end function if session("counter")=empty then session("counter")=counts("counter.txt") end if %>