Yesterday, a friend had a request to modify the time on the IIS server through WEB. Since his system was developed under ASP 3.0, the code in this example is ASP, not ASP.NET, but I am writing this article. I just want to throw some light on things. After all, the key to writing a program is not language, but more importantly, an idea. If you understand programming language as a tool, and understand programming ideas as ideas and methods for solving problems, then the program you write is: using " Tools" are used to solve a problem according to the "ideas" of solving the problem.
First of all, I would like to thank the netizen "Xiaohu". I rewritten it after reading an article he wrote on the Internet about using VB 6.0 to write DLL components FOR ASP. His DLL code only realized rewriting hours and minutes. I added years. , month, day, second modification.
First, create an ActiveX Dll project in VB 6.0. The information is as follows:
Project name: systimeset
Class module name: timeset
The class module code of VB 6.0 is as follows:
1Option Explicit
2Private SystemTime As SystemTime
3Private Declare Function SetSystemTime()Function SetSystemTime Lib "kernel32" (lpSystemTime As SystemTime) As Long
4Private Type System Time
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
twenty three
24' Modified by Li Xiyuan Modification date: 2006-08-31 Modification item: Add operations for year, month, day, and seconds
25'--------------------
26' years
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' months
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' day
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' seconds
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
Compile it into a file called systimeset.dll.
Regarding the registration of DLL, usually VB will automatically register the DLL after it is compiled on the local machine; but if you want to put it on the IIS server, please use the following method:
1. Copy systimeset.dll to c:WINDOWSsystem32;
2. In the run menu, enter: regsvr32 systimeset.dll (hit Enter)
3. Because the INTERNET guest account does not have this permission to modify the server's time, to set up permissions, please open "Administrative Tools" in the control panel, then open "Local Security Policy" - "User Rights Assignment", double-click "Change System Time" ”, click “Add User or Group” in the pop-up dialog box, and add the INETNET guest account.
4. After everything is completed, restart the IIS service once.
After the above settings are completed, the ASP code page using the systimeset.dll component is as follows:
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())
16obj.setup
17
18set obj=Nothing
19end function
20
21if request("act")="modi" then
22 call SetTime(request.Form("strYear"),request.Form("strMonth"),request.Form
twenty three
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="Modification date" /></td>
40 </tr>
41 </table>
42</form>
43
The above is all the implemented code. If you have any questions, please add me at QQ: 17020415.
Paste the above ASP code page into an empty ASP file, and then set up the site in IIS. (It is also possible to set up an IIS virtual directory.)
http://www.cnblogs.com/lixyvip/archive/2006/09/02/492693.html