Foros del Web » Programación para mayores de 30 ;) » Programación General »

Obtener fecha y hora de un servidor

Estas en el tema de Obtener fecha y hora de un servidor en el foro de Programación General en Foros del Web. Tengo que obtener la fecha y la hora de un servidor remoto mediante codigo de visual basic. Gracias por vuestras respuestas....
  #1 (permalink)  
Antiguo 19/04/2004, 10:35
 
Fecha de Ingreso: abril-2004
Ubicación: MURCIA
Mensajes: 11
Antigüedad: 20 años, 10 meses
Puntos: 0
Exclamación Obtener fecha y hora de un servidor

Tengo que obtener la fecha y la hora de un servidor remoto mediante codigo de visual basic.

Gracias por vuestras respuestas.
  #2 (permalink)  
Antiguo 19/04/2004, 10:43
Avatar de Jorge_Mota  
Fecha de Ingreso: diciembre-2002
Ubicación: Chapinlandia :-D
Mensajes: 725
Antigüedad: 22 años, 2 meses
Puntos: 11
revisa si esto te sirve (tomado de www.allapi.net)
'Example by Chaz Branham ([email protected])

'This example show's you how to use the api
'call NetRemoteTOD in vb. It also has some
'other code where it updates your system time
'with the server's time. Very easy to follow
'and short and to the point.

Option Explicit
Private Declare Function NetRemoteTOD Lib "Netapi32.dll" (yServer As Any, pBuffer As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pTo As Any, uFrom As Any, ByVal lSize As Long)
Private Declare Function NetApiBufferFree Lib "netapi32" (ByVal lpBuffer As Long) As Long
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private 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 Type
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
Private Sub Form_Load()
Dim TimeMemoryBuffer As Long, result As Long, TOD As TIME_OF_DAY_INFO, Servername() As Byte
Dim sys_sync As SYSTEMTIME
' Note Servername has to be an Array Byte for this to work properly!
' This servername must be a valid Windows Network server; if it doesn't
' exist, your application might crash!
Servername = "\\Columbus-fs02" & vbNullChar
result = NetRemoteTOD(Servername(0), TimeMemoryBuffer)
CopyMemory TOD, ByVal (TimeMemoryBuffer), LenB(TOD)
Me.AutoRedraw = True
Me.Print "Day:" & TOD.tod_day
Me.Print "Month:" & TOD.tod_month
Me.Print "Year:" & TOD.tod_year
Me.Print "Hours:" & TOD.tod_hours
Me.Print "Minutes:" & TOD.tod_mins
Me.Print "Seconds:" & TOD.tod_secs
Call NetApiBufferFree(TimeMemoryBuffer)
With sys_sync
.wHour = TOD.tod_hours
.wMinute = TOD.tod_mins
.wSecond = TOD.tod_secs
.wDay = TOD.tod_day
.wMonth = TOD.tod_month
.wYear = TOD.tod_year
End With
SetSystemTime sys_sync
End Sub
__________________
Jorge Mota
Blog
Gubiz estafa
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:39.