Using Asp+dll to implement Web-Modified server time _ Application techniques

Source: Internet
Author: User
Yesterday a friend had a need to modify the time on the IIS server through the Web, because his system was developed under ASP 3.0, so the code for this example is ASP, Not asp.net, but I write this article is to make a note, after all, writing program is not the key to language, more important is a thought, the process of language as a tool to understand programming thinking as a solution to the problem of ideas and methods, then write the program is: the use of "tools" according to solve the problem of the idea "To solve a problem.

First of all, to thank netizens "Tiger", I read on the Internet he wrote an article on VB 6.0 to write DLL components for ASP's article rewrite, his DLL code only to achieve the rewrite hours and minutes, I increased the year, month, day, second modification.

First of all, in VB 6.0 to establish an ActiveX DLL project, the information is as follows:

Project Name: Systimeset
class module Name: Timeset

VB 6.0 class module code is as follows:
Copy Code code as follows:

Option Explicit
Private SystemTime as SystemTime
Private Declare function SetSystemTime () function SetSystemTime Lib "kernel32" (Lpsystemtime as SystemTime) as Long
Private Type SystemTime
Wyear as Integer
Wmonth as Integer
Wdayofweek as Integer
Wday as Integer
Whour as Integer
Wminute as Integer
Wsecond as Integer
Wmilliseconds as Integer
End Type

Dim tmp

Private M_hour as Integer
Private M_minute as Integer
Private M_year as Integer
Private M_month as Integer
Private M_day as Integer
Private M_second as Integer

Modified by Li Xiyuan Modification Date: 2006-08-31 Modify item: Increase the operation of year, month, day, and second
'--------------------
' Year
Public Property Get () Property Get year () as Integer
Year = M_year
End Property
Public Property Let (Tmp_year as Integer)
M_year = Tmp_year
End Property
'--------------------
' Month
Public Property Get () Property Get Month () as Integer
Month = M_month
End Property
Public Property Let () Property Let Month (Tmp_month as Integer)
M_month = Tmp_month
End Property
'--------------------
' Day
Public Property Get () Property Get Day () as Integer
Day = M_day
End Property
Public Property Let (Tmp_day as Integer)
M_day = Tmp_day
End Property
'--------------------
' sec
Public Property Get () Property Get Second () as Integer
Second = M_second
End Property
Public Property Let () Property Let Second (Tmp_second as Integer)
M_second = Tmp_second
End Property



Public Property Get () Property Get Hour () as Integer
Hour = M_hour
End Property
Public Property Let () Property Let Hour (Tmp_hour as Integer)
M_hour = Tmp_hour
End Property
Public Property Get () Property Get Minute () as Integer
Minute = M_minute
End Property
Public Property Let () Property Let Minute (Tmp_minute as Integer)
M_minute = Tmp_minute
End Property

Public Function Setup () function setup () as Integer
Systemtime.wday = Day
' Systemtime.wdayofweek = 1
Systemtime.wmilliseconds = 0
Systemtime.wmonth = Month
Systemtime.wsecond = Second
Systemtime.wyear = Year
Systemtime.whour = Hour
Systemtime.wminute = Minute
Setup = SetSystemTime (SystemTime)
End Function

The file that compiles it to systimeset.dll.

With regard to the registration of DLLs, normally VB will register the DLL automatically after it is compiled on this computer, but if you want to put it on the IIS server, use the following method:
1, copy the Systimeset.dll to the c:\WINDOWS\system32;
2, in the beginning of the operation of the menu input: regsvr32 systimeset.dll (hit enter AH)
3, because the time to modify the server, the Internet Guest account does not have this permission, set up permissions open Administrative tools in the Control Panel, open Local Security policy-User Rights Assignment, double-click Change System time, and in the dialog box that pops up, add users or groups. Join the Inetnet Guest account.
4. After you have finished, restart the IIS service once.


When the above settings are complete, the ASP code page using the Systimeset.dll component is as follows:

Copy Code code as follows:

<% @language = "VBScript"%>
<%
function SetTime (stryear,strmonth,strday)
Response. Expires=0
Set Obj=server.createobject ("Systimeset.timeset")
Obj. Year=stryear
Obj. Month=strmonth
Obj. Day=strday
If Hour (now ()) -8>0 Then
Obj. Hour=hour (now ())-8
Else
Obj. Hour=8
End If
Obj. Minute=minute (now ())
Obj. Second=second (now ())
Obj.setup

Set obj=nothing
End Function

If Request ("act") = "Modi" then
Call SetTime (Request. Form ("Stryear"), request. Form ("Strmonth"), request. Form

("Strday"))
End If
%>
<form id= "Form1" Name= "Form1" method= "Post" action= "Act=modi" >
<table width= "290" border= "0" >
<tr>
&LT;TD width= "><input name=" stryear "type=" text "id=" stryear "value=" <%=year (Now ())%> "size=" 8 "/> </td>
&LT;TD width= "><input name=" Strmonth "type=" text "id=" Strmonth "value=" <%=month (Now ())%> "size=" 5 " ></td>
&LT;TD width= "><input name=" Strday "type=" text "id=" Strday "value=" <%=day (Now ())%> "size=" 5 "/>< /TD>
&LT;TD width= "><input" type= "Submit" name= "Submit" value= "Modified Date"/></td>
</tr>
</table>
</form>

The above is all implemented code, there are problems can add me qq:17020415

Paste the above ASP code page into an empty ASP file, and then set up the site in IIS. (You can also set up an IIS virtual directory.) )


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.