Retroceder   Foros del Web > Temas generales de computación > Programación

Respuesta
 
Herramientas Desplegado
Antiguo 19-abr-2004, 10:35   #1 (permalink)
jessi está en el buen camino
 
Fecha de Ingreso: abril-2004
Ubicación: MURCIA
Mensajes: 11
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.
jessi está desconectado   Responder Citando
Antiguo 19-abr-2004, 10:43   #2 (permalink)
Jorge_Mota tiene algunos puntos positivos de karma
 
Avatar de Jorge_Mota
 
Fecha de Ingreso: diciembre-2002
Ubicación: Chapinlandia :-D
Mensajes: 714
revisa si esto te sirve (tomado de www.allapi.net)
'Example by Chaz Branham (bran2@zande.com)

'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 está desconectado   Responder Citando
Respuesta

No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 16:16.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93