delphi4arab منتديات دلفي للعرب

نسخة كاملة : كيف استخرج التاريخ من الانترنيت و اضعه في ايديت ؟
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم اخواني

اولا :  كيف اتحقق من وجود اتصال من عدمه مع اخبار المستخدم بذالك  ؟ 

ثانيا  : عند وجود اتصال كيف استخرج التاريخ  من الانترنيت و وضعه في ايديت ؟

ثالثا  : كيف اجعل البرنامج يصحح تاريخ الجهاز تلقائيا مع وجود اتصال ؟

و شكرا
وعليكم السلام

التحقق من الاتصال بالانترنت


كود :
function YourFunctionName : boolean;   var      origin : cardinal;   begin      result := InternetGetConnectedState(@origin,0);      //connections origins by origin value      //NO INTERNET CONNECTION              = 0;      //INTERNET_CONNECTION_MODEM           = 1;      //INTERNET_CONNECTION_LAN             = 2;      //INTERNET_CONNECTION_PROXY           = 4;      //INTERNET_CONNECTION_MODEM_BUSY      = 8;   end;


او جرب

كود :
function TMainF.isInternetConnection: Boolean; begin   try     IdHTTP.Get('http://www.svtech.cz');   except     on E: Exception do begin       if not (E is EIdHTTPProtocolException) then begin         Result := False;         Exit;       end;     end;   end;   Result := True; end;


الحصول على التاريخ والوقت

كود :
var   SNTPClient: TIdSNTP; begin   SNTPClient := TIdSNTP.Create(nil);   try     SNTPClient.Host := 'pool.ntp.org';     SNTPClient.SyncTime;   finally     SNTPClient.Free;   end; end;


كود :
Label1.Caption := DateToStr(IdSNTP1.DateTime)    + ' - ' + TimeToStr(IdSNTP1.DateTime); Label2.Caption := IdSNTP1.Host;


تغيير التاريخ

كود :
var   myDateTime, newDate : TDateTime; begin   // Set the date to 29/10/2002 at 12:34:56   myDateTime := EncodeDateTime(2002, 10, 29, 12, 34, 56, 0);   ShowMessage('The starting date/time = '+DateTimeToStr(myDateTime));   // Now change the date portion without touching the time   newDate := EncodeDate(1957, 02, 18);   ReplaceDate(myDateTime, newDate);   ShowMessage('The new date/time = '+DateTimeToStr(myDateTime)); end;

تغيير الوقت

كود :
var   myDateTime, newTime : TDateTime; begin   // Set the date to 29/10/2002 at 12:34:56   myDateTime := EncodeDateTime(2002, 10, 29, 12, 34, 56, 0);   ShowMessage('The starting date/time = '+DateTimeToStr(myDateTime));   // Now change the time portion without touching the date   newTime := EncodeTime(9, 45, 52, 0);   ReplaceTime(myDateTime, newTime);   ShowMessage('The new date/time = '+DateTimeToStr(myDateTime)); end;
PHP كود :
Uses  IdSNTP  ;
procedure TForm1.FormCreate(Sender: TObject);

var
  SNTPClient: TIdSNTP;
begin
  SNTPClient 
:= TIdSNTP.Create(nil);
  try
    SNTPClient.Host := 'time.windows.com';
    SNTPClient.SyncTime;
    Label1.Caption := DateToStr(SNTPClient.DateTime)+ ' - ' + TimeToStr(SNTPClient.DateTime);
    Label2.Caption := SNTPClient.Host;
  // ShowMessage(DateTimeToStr(SNTPClient.DateTime));
  finally
    SNTPClient.Free;
  end;
end;