jhonalone,
Cita:
Empezado por jhonalone
...Estoy intentando ver la fecha de modificación de un fichero que está en mi página de internet...
|
Revisa este código:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinInet;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetLastModifiedDate(Url : String) : TDateTime;
var
hInet : HINTERNET;
hUrl : HINTERNET;
LastModifiedDate : SYSTEMTIME;
SizeDate : DWORD;
Index : DWORD;
begin
try
hInet := InternetOpen(PChar(Application.Title),INTERNET_OPEN_TYPE_PRECONFIG,nil,nil,0);
hUrl := InternetOpenURL(hInet,PChar(Url),nil,0,0,0);
SizeDate := SizeOf(LastModifiedDate);
Index := 0;
if HttpQueryInfo(hUrl,
HTTP_QUERY_LAST_MODIFIED or HTTP_QUERY_FLAG_SYSTEMTIME,
@LastModifiedDate,
SizeDate,
Index)
then
Result := SystemTimeToDateTime(LastModifiedDate)
else
Result := 0;
finally
InternetCloseHandle(hUrl);
InternetCloseHandle(hInet);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Url : String;
LastModifiedDate : String;
begin
Url := 'http://www.math-magic.com/pdf_files/basic_memorization/prime.pdf';
LastModifiedDate := FormatDateTime('yyyy/mm/dd hh:mm:ss',GetLastModifiedDate(Url));
MessageDlg(LastModifiedDate,mtInformation,[mbOK],0);
end;
end.
El código anterior en Delphi 7 sobre Windows 7 Professional x32,
obtiene la fecha de última modificación de un recurso url por medio de las funciones de
Windows Internet (WinINet) application programming interface (API) .
Espero sea útil
Nelson.