rones 0 Posted January 31, 2023 HELP PLEASE. I'm using the library above to connect to the internet and get the date, but depending on the wifi connection I use, the system generates an exception and doesn't connect to the internet. What can i do? Follow the line of code below: function internetdate: TDateTime; var IdSNTP: TIDSntp; begin IdSNTP := TIDSntp.Create(nil); try IdSNTP.Host := 'pool.ntp.br'; Application.ProcessMessages; Result := IdSNTP.DateTime; Application.ProcessMessages; finally IdSNTP.Free; end; end Share this post Link to post
programmerdelphi2k 237 Posted January 31, 2023 (edited) why you needs 2 "Application.ProcessMessages" ? procedure TForm1.Button1Click(Sender: TObject); var LIdSNTP: TIdSNTP; begin LIdSNTP := TIdSNTP.Create(nil); try LIdSNTP.Host := 'pool.ntp.br'; Label1.Caption := DateTimeToStr(LIdSNTP.DateTime); // working! finally LIdSNTP.Free; end; end; Edited January 31, 2023 by programmerdelphi2k Share this post Link to post
Remy Lebeau 1394 Posted January 31, 2023 (edited) 58 minutes ago, rones said: HELP PLEASE. I'm using the library above to connect to the internet TIdSNTP, and Indy in general, does not connect you to the Internet. You have to already be connected beforehand. It would be more accurate to say that you are using TIdSNTP to connect to a remote time server that is accessible over the Internet. Quote and get the date, but depending on the wifi connection I use, the system generates an exception What type of exception are you seeing, exactly? What does it say? Please be more specific. Edited January 31, 2023 by Remy Lebeau Share this post Link to post
aehimself 396 Posted February 4, 2023 I'm sorry, but that command became my Achilles heel. Don't use it. 1 Share this post Link to post