最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2006年09月14日 00:00:00   作者:  
昨天一個(gè)朋友有個(gè)需求,是要通過(guò)WEB方式,修改IIS服務(wù)器上的時(shí)間,由于他的系統(tǒng)是ASP 3.0下開發(fā)的,所以本例子的代碼是ASP的,不是ASP.NET,但是本人寫這個(gè)文章是想拋磚引玉,畢竟編寫程序關(guān)鍵的不是語(yǔ)言,更重要的是一種思想,把程序語(yǔ)言理解為一種工具,把編程思想理解為解決問(wèn)題的思路和方法,那么編寫出來(lái)的程序就是:利用“工具”按照解決問(wèn)題的“思想”去解決一個(gè)問(wèn)題。

首先,要感謝網(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來(lái)賓帳戶不具有該權(quán)限,設(shè)立權(quán)限請(qǐng)打開控制面版中的“管理工具”,然后打開“本地安全策略”--“用戶權(quán)力指派”,雙擊“更改系統(tǒng)時(shí)間”,在彈出的對(duì)話框中點(diǎn)“添加用戶或組”,將INETNET來(lái)賓帳戶加入進(jìn)來(lái)。
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)的代碼,有問(wèn)題可以加我QQ:17020415

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


相關(guān)文章

最新評(píng)論

吴川市| 蒙城县| 南和县| 宁波市| 崇义县| 闻喜县| 石狮市| 蓝田县| 乌拉特前旗| 太谷县| 闵行区| 简阳市| 龙陵县| 禄劝| 宁海县| 沾化县| 荥经县| 岐山县| 芦山县| 恩施市| 炎陵县| 平邑县| 汝州市| 海安县| 新竹市| 泽普县| 阿瓦提县| 馆陶县| 通渭县| 顺义区| 萨迦县| 丽江市| 宜都市| 鄂托克前旗| 上栗县| 霍林郭勒市| 五家渠市| 稻城县| 上犹县| 贵南县| 冷水江市|