主頁(yè) > 知識(shí)庫(kù) > 用ASP+DLL實(shí)現(xiàn)WEB方式修改服務(wù)器時(shí)間

用ASP+DLL實(shí)現(xiàn)WEB方式修改服務(wù)器時(shí)間

熱門標(biāo)簽:怎么在地圖標(biāo)注自己 外呼系統(tǒng)API接口 縣域地圖標(biāo)注打印店 鳳臺(tái)百度地圖標(biāo)注店 萊西電子地圖標(biāo)注 個(gè)人可以辦理400電話么 金昌電話機(jī)器人價(jià)格 武夷山旅游地圖標(biāo)注 修改地圖標(biāo)注
昨天一個(gè)朋友有個(gè)需求,是要通過WEB方式,修改IIS服務(wù)器上的時(shí)間,由于他的系統(tǒng)是ASP 3.0下開發(fā)的,所以本例子的代碼是ASP的,不是ASP.NET,但是本人寫這個(gè)文章是想拋磚引玉,畢竟編寫程序關(guān)鍵的不是語言,更重要的是一種思想,把程序語言理解為一種工具,把編程思想理解為解決問題的思路和方法,那么編寫出來的程序就是:利用“工具”按照解決問題的“思想”去解決一個(gè)問題。

首先,要感謝網(wǎng)友“小虎”,我是在網(wǎng)上看了他寫的一篇關(guān)于用VB 6.0編寫DLL組件FOR ASP的文章改寫的,他的DLL代碼只實(shí)現(xiàn)了改寫小時(shí)和分鐘,我增加了年、月、日、秒的修改。

首先,在VB 6.0中建立一個(gè)ActiveX Dll工程項(xiàng)目,信息如下:

工程名稱:systimeset
類模塊名稱:timeset

VB 6.0的類模塊代碼如下:
復(fù)制代碼 代碼如下:

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

'由李錫遠(yuǎn)修改     修改日期:2006-08-31     修改項(xiàng)目:增加對(duì)年、月、日、秒的操作
'--------------------
'年
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 = 1
SystemTime.wMilliseconds = 0
SystemTime.wMonth = Month
SystemTime.wSecond = Second
SystemTime.wYear = Year
SystemTime.wHour = Hour
SystemTime.wMinute = Minute
setup = SetSystemTime(SystemTime)
End Function

將其編譯為systimeset.dll的文件。

關(guān)于DLL的注冊(cè),通常VB在本機(jī)上編譯后,會(huì)自動(dòng)將DLL注冊(cè);但如果你要放到IIS服務(wù)器上,請(qǐng)使用如下方法:
1、將systimeset.dll拷貝到c:\WINDOWS\system32下;
2、在開始菜單的運(yùn)行里面輸入:regsvr32 systimeset.dll     (敲回車啊)
3、因?yàn)樾薷姆?wù)器的時(shí)間,INTERNET來賓帳戶不具有該權(quán)限,設(shè)立權(quán)限請(qǐng)打開控制面版中的“管理工具”,然后打開“本地安全策略”--“用戶權(quán)力指派”,雙擊“更改系統(tǒng)時(shí)間”,在彈出的對(duì)話框中點(diǎn)“添加用戶或組”,將INETNET來賓帳戶加入進(jìn)來。
4、一切完畢后,將IIS服務(wù)重新啟動(dòng)一次。


在上面的設(shè)置完畢后,使用systimeset.dll組件的ASP代碼頁(yè)面如下:

復(fù)制代碼 代碼如下:

% @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>
      td width="77">input name="strYear" type="text" id="strYear" value="%=Year(now())%>" size="8" />/td>
     td width="49">input name="strMonth" type="text" id="strMonth" value="%=Month(now())%>" size="5" />/td>
     td width="48">input name="strDay" type="text" id="strDay" value="%=Day(now())%>" size="5" />/td>
     td width="98">input type="submit" name="Submit" value="修改日期" />/td>
   /tr>
 /table>
/form>

以上是所有實(shí)現(xiàn)的代碼,有問題可以加我QQ:17020415

將上面的ASP代碼頁(yè)面粘貼到一個(gè)空的ASP文件中,然后在IIS中將站點(diǎn)設(shè)置好就可以了。(設(shè)置IIS虛擬目錄也可以的。)


標(biāo)簽:通遼 南京 邢臺(tái) 涼山 清遠(yuǎn) 赤峰 楚雄 上海

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用ASP+DLL實(shí)現(xiàn)WEB方式修改服務(wù)器時(shí)間》,本文關(guān)鍵詞  用,ASP+DLL,實(shí)現(xiàn),WEB,方式,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《用ASP+DLL實(shí)現(xiàn)WEB方式修改服務(wù)器時(shí)間》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于用ASP+DLL實(shí)現(xiàn)WEB方式修改服務(wù)器時(shí)間的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章