大家好!如何在 VB6.0 中取得局域网中某一机器的时间?谢谢!
解决方案 »
- 请问将word模板中的表格数据导入到MSFlexGrid里有没有办法提供速度?
- 如何将多个文本框内的内容作为一个新记录追加到数据库
- form2.0中的COMBOBOX为何不支持滚动鼠标?
- 超市收银系统的扫描枪问题
- 討論一下工資問題吧.
- 大家来帮忙: 如何获得文本框中光标的位置
- 怎么得到 一个字段的长度和类型
- 急问:一个sql语句的语法问题
- 关于VB中当前控件的问题.
- VB高手们,我怎样实现数据库中数据的同步?如,表1中有字段A、B、C、D,在表2中有C、D、E、F,我在表1中改变了C、D的值,怎样实现表2中的
- Public dbObj As ADODB.Connection提示ADODB没有定义,怎么回事啊?
- winsock.connect 方法为什么有时不运行winsock_connect()事件?
讀取網絡服務器當前時間Option Explicit
Private Declare Function NetRemoteTOD Lib "Netapi32.dll" (tServer As Any, pBuffer As Long) As LongPrivate 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 TypePrivate Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(32) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(32) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End TypePrivate Declare Function GetTimeZoneInformation Lib "kernel32" ( _
lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Private Declare Function NetApiBufferFree Lib "Netapi32.dll" (ByVal lpBuffer As Long) As LongPrivate Type TIME_OF_DAY_INFO
tod_elapsedt As Long
tod_msecs As Long
tod_hours As Long
tod_mins As Long
tod_secs As Long
tod_hunds As Long
tod_timezone As Long
tod_tinterval As Long
tod_day As Long
tod_month As Long
tod_year As Long
tod_weekday As Long
End TypePrivate Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
Destination As Any, Source As Any, ByVal Length As Long)Public Function getRemoteTOD(ByVal strServer As String) As Date
Dim result As Date
Dim lRet As Long
Dim tod As TIME_OF_DAY_INFO
Dim lpbuff As Long
Dim tServer() As Byte
tServer = strServer & vbNullChar
lRet = NetRemoteTOD(tServer(0), lpbuff)
If lRet = 0 Then
CopyMemory tod, ByVal lpbuff, Len(tod)
NetApiBufferFree lpbuff
result = DateSerial(tod.tod_year, tod.tod_month, tod.tod_day) + _
TimeSerial(tod.tod_hours, tod.tod_mins - tod.tod_timezone, tod.tod_secs)
getRemoteTOD = result
Else
Err.Raise Number:=vbObjectError + 1001, _
Description:="cannot get remote TOD"
End If
End FunctionPrivate Sub Command1_Click()
Dim d As Date
d = getRemoteTOD("E08-065")
MsgBox d
End Sub