导读: 首先,在VB 6.0中建立一个ActiveX Dll工程项目,信息如下: 工程名称:systimeset 类模块名称:timeset VB 6.0的类模块代码如下:1Op...
首先,在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 5wYear As Integer 6wMonth As Integer 7wDayOfWeek As Integer 8wDay As Integer 9wHour As Integer10wMinute As Integer11wSecond As Integer12wMilliseconds As Integer13End Type1415Dim tmp1617Private m_Hour As Integer18Private m_Minute As Integer19Private m_Year As Integer20Private m_Month As Integer21Private m_Day As Integer22Private m_Second As Integer2324'由李锡远修改修改日期:2006-08-31修改项目:增加对年、月、日、秒的操作25'--------------------26'年27Public Property Get()Property Get Year() As Integer28Year = m_Year29End Property30Public Property Let()Property Let Year(tmp_Year As Integer)31m_Year = tmp_Year32End Property33'--------------------34'月35Public Property Get()Property Get Month() As Integer36Month = m_Month37End Property38Public Property Let()Property Let Month(tmp_Month As Integer)39m_Month = tmp_Month40End Property41'--------------------42'日43Public Property Get()Property Get Day() As Integer44Day = m_Day45End Property46Public Property Let()Property Let Day(tmp_Day As Integer)47m_Day = tmp_Day48End Property49'--------------------50'秒51Public Property Get()Property Get Second() As Integer52Second = m_Second53End Property54Public Property Let()Property Let Second(tmp_Second As Integer)55m_Second = tmp_Second56End Property57585960Public Property Get()Property Get Hour() As Integer61Hour = m_Hour62End Property63Public Property Let()Property Let Hour(tmp_Hour As Integer)64m_Hour = tmp_Hour65End Property66Public Property Get()Property Get Minute() As Integer67Minute = m_Minute68End Property69Public Property Let()Property Let Minute(tmp_Minute As Integer)70m_Minute = tmp_Minute71End Property7273747576Public Function setup()Function setup() As Integer77SystemTime.wDay = Day78'SystemTime.wDayOfWeek = 179SystemTime.wMilliseconds = 080SystemTime.wMonth = Month81SystemTime.wSecond = Second82SystemTime.wYear = Year83SystemTime.wHour = Hour84SystemTime.wMinute = Minute85setup = SetSystemTime(SystemTime)8687End Function88
关于DLL的注册,通常VB在本机上编译后,会自动将DLL注册;但如果你要放到IIS服务器上,请使用如下方法:
1、将systimeset.dll拷贝到c:WINDOWSsystem32下;
2、在开始菜单的运行里面输入:regsvr32 systimeset.dll(敲回车啊)
3、因为修改服务器的时间,INTERNET来宾帐户不具有该权限,设立权限请打开控制面版中的“管理工具”,然后打开“本地安全策略”--“用户权力指派”,双击“更改系统时间”,在弹出的对话框中点“添加用户或组”,将INETNET来宾帐户加入进来。
4、一切完毕后,将IIS服务重新启动一次。
在上面的设置完毕后,使用systimeset.dll组件的ASP代码页面如下:
将其编译为systimeset.dll的文件。
1<% @language="vbscript" %> 2<% 3function SetTime(strYear,strMonth,strDay) 4response.Expires=0 5set obj=server.createobject("systimeset.timeset") 6obj.Year=strYear 7obj.Month=strMonth 8obj.Day=strDay 9if Hour(now())-8>0 then10obj.Hour=Hour(now())-811else12obj.Hour=813end if14obj.Minute=Minute(now())15obj.Second=Second(now())16obj.setup1718set obj=Nothing19end function2021if request("act")="modi" then22call SetTime(request.Form("strYear"),request.Form("strMonth"),request.Form2324("strDay"))25end if26%>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())%>" 3132size="8" /></td>33<td width="49"><input name="strMonth" type="text" id="strMonth" value="<%=Month(now3435())%>" size="5" /></td>36<td width="48"><input name="strDay" type="text" id="strDay" value="<%=Day(now())%>" 3738size="5" /></td>39<td width="98"><input type="submit" name="Submit" value="修改日期" /></td>40</tr>41</table>42</form>43
将上面的ASP代码页面粘贴到一个空的ASP文件中,然后在IIS中将站点设置好就可以了。(设置IIS虚拟目录也可以的。)
赞助本站