用ASP+DLL实现WEB方式修改服务器时间
点击次数:23 次 发布日期:2008-11-26 12:25:24 作者:源代码网
|
源代码网推荐 源代码网推荐 首先,要感谢网友“小虎”,我是在网上看了他写的一篇关于用VB 6.0编写DLL组件FOR ASP的文章改写的,他的DLL代码只实现了改写小时和分钟,我增加了年、月、日、秒的修改。 源代码网推荐 源代码网推荐 首先,在VB 6.0中建立一个ActiveX Dll工程项目,信息如下: 源代码网推荐 源代码网推荐 工程名称:systimeset 源代码网推荐 类模块名称:timeset 源代码网推荐 源代码网推荐 VB 6.0的类模块代码如下: 源代码网推荐 源代码网推荐 源代码网推荐 1Option Explicit 源代码网推荐 2Private SystemTime As SystemTime 源代码网推荐 3Private Declare Function SetSystemTime()Function SetSystemTime Lib "kernel32" (lpSystemTime As SystemTime) As Long 源代码网推荐 4Private Type SystemTime 源代码网推荐 5 wYear As Integer 源代码网推荐 6 wMonth As Integer 源代码网推荐 7 wDayOfWeek As Integer 源代码网推荐 8 wDay As Integer 源代码网推荐 9 wHour As Integer 源代码网推荐 10 wMinute As Integer 源代码网推荐 11 wSecond As Integer 源代码网推荐 12 wMilliseconds As Integer 源代码网推荐 13End Type 源代码网推荐 14 源代码网推荐 15Dim tmp 源代码网推荐 16 源代码网推荐 17Private m_Hour As Integer 源代码网推荐 18Private m_Minute As Integer 源代码网推荐 19Private m_Year As Integer 源代码网推荐 20Private m_Month As Integer 源代码网推荐 21Private m_Day As Integer 源代码网推荐 22Private m_Second As Integer 源代码网推荐 23 源代码网推荐 24"由李锡远修改 修改日期:2006-08-31 修改项目:增加对年、月、日、秒的操作 源代码网推荐 25"-------------------- 源代码网推荐 26"年 源代码网推荐 27Public Property Get()Property Get Year() As Integer 源代码网推荐 28Year = m_Year 源代码网推荐 29End Property 源代码网推荐 30Public Property Let()Property Let Year(tmp_Year As Integer) 源代码网推荐 31m_Year = tmp_Year 源代码网推荐 32End Property 源代码网推荐 33"-------------------- 源代码网推荐 34"月 源代码网推荐 35Public Property Get()Property Get Month() As Integer 源代码网推荐 36Month = m_Month 源代码网推荐 37End Property 源代码网推荐 38Public Property Let()Property Let Month(tmp_Month As Integer) 源代码网推荐 39m_Month = tmp_Month 源代码网推荐 40End Property 源代码网推荐 41"-------------------- 源代码网推荐 42"日 源代码网推荐 43Public Property Get()Property Get Day() As Integer 源代码网推荐 44Day = m_Day 源代码网推荐 45End Property 源代码网推荐 46Public Property Let()Property Let Day(tmp_Day As Integer) 源代码网推荐 47m_Day = tmp_Day 源代码网推荐 48End Property 源代码网推荐 49"-------------------- 源代码网推荐 50"秒 源代码网推荐 51Public Property Get()Property Get Second() As Integer 源代码网推荐 52Second = m_Second 源代码网推荐 53End Property 源代码网推荐 54Public Property Let()Property Let Second(tmp_Second As Integer) 源代码网推荐 55m_Second = tmp_Second 源代码网推荐 56End Property 源代码网推荐 57 源代码网推荐 58 源代码网推荐 59 源代码网推荐 60Public Property Get()Property Get Hour() As Integer 源代码网推荐 61Hour = m_Hour 源代码网推荐 62End Property 源代码网推荐 63Public Property Let()Property Let Hour(tmp_Hour As Integer) 源代码网推荐 64m_Hour = tmp_Hour 源代码网推荐 65End Property 源代码网推荐 66Public Property Get()Property Get Minute() As Integer 源代码网推荐 67Minute = m_Minute 源代码网推荐 68End Property 源代码网推荐 69Public Property Let()Property Let Minute(tmp_Minute As Integer) 源代码网推荐 70m_Minute = tmp_Minute 源代码网推荐 71End Property 源代码网推荐 72 源代码网推荐 73 源代码网推荐 74 源代码网推荐 75 源代码网推荐 76Public Function setup()Function setup() As Integer 源代码网推荐 77SystemTime.wDay = Day 源代码网推荐 78"SystemTime.wDayOfWeek = 1 源代码网推荐 79SystemTime.wMilliseconds = 0 源代码网推荐 80SystemTime.wMonth = Month 源代码网推荐 81SystemTime.wSecond = Second 源代码网推荐 82SystemTime.wYear = Year 源代码网推荐 83SystemTime.wHour = Hour 源代码网推荐 84SystemTime.wMinute = Minute 源代码网推荐 85setup = SetSystemTime(SystemTime) 源代码网推荐 86 源代码网推荐 87End Function 源代码网推荐 88 源代码网推荐 将其编译为systimeset.dll的文件。 源代码网推荐 源代码网推荐 关于DLL的注册,通常VB在本机上编译后,会自动将DLL注册;但如果你要放到IIS服务器上,请使用如下方法: 源代码网推荐 1、将systimeset.dll拷贝到c:WINDOWSsystem32下; 源代码网推荐 2、在开始菜单的运行里面输入:regsvr32 systimeset.dll (敲回车啊) 源代码网推荐 3、因为修改服务器的时间,INTERNET来宾帐户不具有该权限,设立权限请打开控制面版中的“管理工具”,然后打开“本地安全策略”--“用户权力指派”,双击“更改系统时间”,在弹出的对话框中点“添加用户或组”,将INETNET来宾帐户加入进来。 源代码网推荐 4、一切完毕后,将IIS服务重新启动一次。 源代码网推荐 源代码网推荐 源代码网推荐 在上面的设置完毕后,使用systimeset.dll组件的ASP代码页面如下: 源代码网推荐 源代码网推荐 源代码网推荐 1<% @language="vbscript" %> 源代码网推荐 2<% 源代码网推荐 3function SetTime(strYear,strMonth,strDay) 源代码网推荐 4response.Expires=0 源代码网推荐 5set obj=server.createobject("systimeset.timeset") 源代码网推荐 6 obj.Year=strYear 源代码网推荐 7 obj.Month=strMonth 源代码网推荐 8 obj.Day=strDay 源代码网推荐 9 if Hour(now())-8>0 then 源代码网推荐 10 obj.Hour=Hour(now())-8 源代码网推荐 11 else 源代码网推荐 12 obj.Hour=8 源代码网推荐 13 end if 源代码网推荐 14 obj.Minute=Minute(now()) 源代码网推荐 15 obj.Second=Second(now()) 源代码网推荐 16 obj.setup 源代码网推荐 17 源代码网推荐 18set obj=Nothing 源代码网推荐 19end function 源代码网推荐 20 源代码网推荐 21if request("act")="modi" then 源代码网推荐 22 call SetTime(request.Form("strYear"),request.Form("strMonth"),request.Form 源代码网推荐 23 源代码网推荐 24("strDay")) 源代码网推荐 25end if 源代码网推荐 26%> 源代码网推荐 27<form id="form1" name="form1" method="post" action="?act=modi"> 源代码网推荐 28 <table width="290" border="0"> 源代码网推荐 29 <tr> 源代码网推荐 30 <td width="77"><input name="strYear" type="text" id="strYear" value="<%=Year(now())%>" 源代码网推荐 31 源代码网推荐 32size="8" /></td> 源代码网推荐 33 <td width="49"><input name="strMonth" type="text" id="strMonth" value="<%=Month(now 源代码网推荐 34 源代码网推荐 35())%>" size="5" /></td> 源代码网推荐 36 <td width="48"><input name="strDay" type="text" id="strDay" value="<%=Day(now())%>" 源代码网推荐 37 源代码网推荐 38size="5" /></td> 源代码网推荐 39 <td width="98"><input type="submit" name="Submit" value="修改日期" /></td> 源代码网推荐 40 </tr> 源代码网推荐 41 </table> 源代码网推荐 42</form> 源代码网推荐 43 源代码网推荐 以上是所有实现的代码,有问题可以加我QQ:17020415 源代码网推荐 源代码网推荐 将上面的ASP代码页面粘贴到一个空的ASP文件中,然后在IIS中将站点设置好就可以了。(设置IIS虚拟目录也可以的。) 源代码网推荐 源代码网推荐 http://www.cnblogs.com/lixyvip/archive/2006/09/02/492693.html 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。 源代码网推荐 源代码网供稿. |
