用ASP+DLL實現WEB方式修改伺服器時間

來源:互聯網
上載者:User

昨天一個朋友有個需求,是要通過WEB方式,修改IIS伺服器上的時間,由於他的系統是ASP 3.0下開發的,所以本例子的代碼是ASP的,不是ASP.NET,但是本人寫這個文章是想拋磚引玉,畢竟編寫程式關鍵的不是語言,更重要的是一種思想,把程式語言理解為一種工具,把編程思想理解為解決問題的思路和方法,那麼編寫出來的程式就是:利用“工具”按照解決問題的“思想”去解決一個問題。

首先,要感謝網友“小虎”,我是在網上看了他寫的一篇關於用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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.