鉴于大家对ASP十分关注,我们编辑小组在此为大家搜集整理了“用ASP+DLL实现WEB方式修改服务器时间”一文,供大家参考学习
昨天一个朋友有个需求,是要通过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的类模块代码如下:
复制代码 代码如下:
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
''由李锡远修改 修改日期:2006-08-31 修改项目:增加对年、月、日、秒的操作
''--------------------
''年
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的文件。
关于DLL的注册,通常VB在本机上编译后,会自动将DLL
注册;但如果你要放到IIS服务器上,请使用如下方法:
1、将systimeset.dll拷贝到c:\WINDOWS\system32下;
2、在开始菜单的运行里面输入:regsvr32 sys