使用api函数,添加一个窗体,在上面画一个按钮,然后添加如下代码Private Declare Function NetRemoteTOD Lib "Netapi32.dll" (yServer As Any, pBuffer As Long) As Long Type TIME_OF_DAY_INFO elapsedt As Long msecs As Long hours As Long mins As Long secs As Long hunds As Long timezone As Long tinterval As Long day As Long month As Long year As Long weekday As Long End Type Dim Tod1 As TIME_OF_DAY_INFO
Private Sub Command1_Click() Dim rc As Long rc = NetRemoteTOD("ServerName", Tod1) Dim yourTime As Long yourTime = Tod1.hours '当前的小时数0-23 yourTime = Tod1.mins '当前的分钟数0-59 yourTime = Tod1.secs '当前的秒数0-59 '以此类推还有tod1.day,Tod1.month,Tod1.year,Tod1.weekdayEnd Sub
Select getdate()
Type TIME_OF_DAY_INFO
elapsedt As Long
msecs As Long
hours As Long
mins As Long
secs As Long
hunds As Long
timezone As Long
tinterval As Long
day As Long
month As Long
year As Long
weekday As Long
End Type
Dim Tod1 As TIME_OF_DAY_INFO
Private Sub Command1_Click()
Dim rc As Long
rc = NetRemoteTOD("ServerName", Tod1)
Dim yourTime As Long
yourTime = Tod1.hours '当前的小时数0-23
yourTime = Tod1.mins '当前的分钟数0-59
yourTime = Tod1.secs '当前的秒数0-59
'以此类推还有tod1.day,Tod1.month,Tod1.year,Tod1.weekdayEnd Sub