| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
ZHAX1 Master

Registrado: 09 Mar 2007Mensajes: 191
|
Publicado: Mie 26 Mar, 2008 6:52 pm Asunto: fecha hora internet parte 2 (SNTP) SIMPLE NETW TIME PROTOCOL |
|
|
He probado con el componente indy sntp
| Código: |
void __fastcall TForm1::Button1Click(TObject *Sender)
{
jj->Host = "time-a.nist.gov";
jj->SyncTime();
e1->Text = DateTimeToStr(jj->DateTime);
} |
pero solo me devuelve la fecha 30/12/1899
Necesito la fecha hora actual recojida de internet con precision. alguna ayuda por favor, nunca he usado los componentes indy, y la ayuda o es muy compleja o no se encuentra. Quiero usar este protocolo para tener servidores fiables y que yo pueda añadir o quitar desde el programa.
Gracias. |
|
| Volver arriba |
|
 |
Angel Master


Registrado: 15 Abr 2003Mensajes: 2311Ubicación: Toledo (España)
|
Publicado: Jue 27 Mar, 2008 8:14 am Asunto: |
|
|
En la ayuda de ese elemento habla de la función GetDateTime:
| Cita: | | The value in DateTime is read using the protected function GetDateTime. GetDateTime creates an TNTPGram datagram , transmits the datagram as a string containing the unicast SNTP request using Send, and retrieves the response using ReceiveString. If the response is not an empty string, TIdSNTP properties are updated with values in the response. |
De SyncTime lo que dice es que sirve apra sincronizar el reloj del PC con el del servidor:
| Cita: | | SyncTime is a Boolean function that updates the clock on the local computer, and returns True if the value of DateTime is not an invalid value and the TNTPGram response is not ignored. |
_________________ Un saludo
Necesitamos tu ayuda: Envía AI al 27595 (Coste 1,20 euros + IVA) |
|
| Volver arriba |
|
 |
ZHAX1 Master

Registrado: 09 Mar 2007Mensajes: 191
|
Publicado: Jue 27 Mar, 2008 9:48 am Asunto: |
|
|
DM->sntp->Host ="hora.host.es";
//DM->sntp->SyncTime();
e1->Text = "Fecha actual "+DateToStr(DM->sntp->DateTime)+" Hora actual "+ TimeToStr(DM->sntp->DateTime);
Funcionando. |
|
| Volver arriba |
|
 |
|