RE:como puedo obtener la hora del servidor
Debes utilizar la API de Windows.
Prueba con esto:
' Referencia
Imports System.Runtime.InteropServices
' Llamadas a la API
Private Declare Unicode Function NetRemoteTOD Lib "netapi32" ( _
<MarshalAs(UnmanagedType.LPWStr)> ByVal ServerName As String, _
ByRef BufferPtr As IntPtr) As Integer
Private Declare Function NetApiBufferFree Lib _
"netapi32" (ByVal Buffer As IntPtr) As Integer
' Estructura necesaria
Structure TIME_OF_DAY_INFO
Dim tod_elapsedt As Integer
Dim tod_msecs As Integer
Dim tod_hours As Integer
Dim tod_mins As Integer
Dim tod_secs As Integer
Dim tod_hunds As Integer
Dim tod_timezone As Integer
Dim tod_tinterval As Integer
Dim tod_day As Integer
Dim tod_month As Integer
Dim tod_year As Integer
Dim tod_weekday As Integer
End Structure
' Copia esto en el Load del formulario para probar
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim iRet As Integer
Dim ptodi As IntPtr
Dim todi As TIME_OF_DAY_INFO
Dim dDate As Date
Dim Servidor As String
' Nombre del servidor acabado en terminación nula
Servidor = "\\NombreDeTuServidor" & vbNullChar
' Recuperamos los datos del servidor
iRet = NetRemoteTOD(Servidor, ptodi)
If iRet = 0 Then
todi = CType(Marshal.PtrToStructure(ptodi, GetType(TIME_OF_DAY_INFO)), TIME_OF_DAY_INFO)
NetApiBufferFree(ptodi)
dDate = DateSerial(todi.tod_year, todi.tod_month, todi.tod_day) + " " + _
TimeSerial(todi.tod_hours, todi.tod_mins - todi.tod_timezone, todi.tod_secs)
MsgBox("La fecha del servidor es " + dDate)
Else
MsgBox("Error recuperando la fecha del servidor")
End If
Catch
MsgBox("Error de aplicación")
End Try
End Sub
Un saludo. ; )