首先在VB 中建立一個ActiveX Dll工程項目信息如下
工程名稱systimeset
類模塊名稱timeset
VB 的類模塊代碼如下
Option Explicit
Private SystemTime As SystemTime
Private Declare Function SetSystemTime()Function SetSystemTime Lib "kernel
" (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
由李錫遠修改 修改日期
修改項目
增加對年
月
日
秒的操作
年
Public Property Get()Property Get Year() As Integer
Year = m_Year
End Property
Public Property Let()Property Let Year(tmp_Year As Integer)
m_Year = tmp_Year
End Property
月
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
日
Public Property Get()Property Get Day() As Integer
Day = m_Day
End Property
Public Property Let()Property Let Day(tmp_Day As Integer)
m_Day = tmp_Day
End Property
秒
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 =
SystemTime
wMilliseconds =
SystemTime
wMonth = Month
SystemTime
wSecond = Second
SystemTime
wYear = Year
SystemTime
wHour = Hour
SystemTime
wMinute = Minute
setup = SetSystemTime(SystemTime)
End Function
關於DLL的注冊
通常VB在本機上編譯後
會自動將DLL注冊
但如果你要放到IIS服務器上
請使用如下方法
將systimeset
dll拷貝到c:WINDOWSsystem
下
在開始菜單的運行裡面輸入
regsvr
systimeset
dll (敲回車啊)
因為修改服務器的時間
INTERNET來賓帳戶不具有該權限
設立權限請打開控制面版中的“管理工具”
然後打開“本地安全策略”--“用戶權力指派”
雙擊“更改系統時間”
在彈出的對話框中點“添加用戶或組”
將INETNET來賓帳戶加入進來
一切完畢後
將IIS服務重新啟動一次
在上面的設置完畢後
使用systimeset
dll組件的ASP代碼頁面如下
將其編譯為systimesetdll的文件
<% @language="vbscript" %>
<%
function SetTime(strYear
strMonth
strDay)
response
Expires=
set obj=server
createobject("systimeset
timeset")
obj
Year=strYear
obj
Month=strMonth
obj
Day=strDay
if Hour(now())
>
then
obj
Hour=Hour(now())
else
obj
Hour=
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="form
" name="form
" method="post" action="?act=modi">
<table width="
" border="
">
<tr>
<td width="
"><input name="strYear" type="text" id="strYear" value="<%=Year(now())%>"
size="
" /></td>
<td width="
"><input name="strMonth" type="text" id="strMonth" value="<%=Month(now
())%>" size="
" /></td>
<td width="
"><input name="strDay" type="text" id="strDay" value="<%=Day(now())%>"
size="
" /></td>
<td width="
"><input type="submit" name="Submit" value="修改日期" /></td>
</tr>
</table>
</form>
將上面的ASP代碼頁面粘貼到一個空的ASP文件中然後在IIS中將站點設置好就可以了(設置IIS虛擬目錄也可以的)
From:http://tw.wingwit.com/Article/program/net/201311/14441.html