Hej
I procedure TForm1.IEfunction GetFileLastAccessTime, forsøger jeg, at gå vider hvis filen findes, men det lykkes ikke.
Gør brug af function GetFileLastAccessTime ved dato angivelse.
Kan du se hvor det går galt?
For en orden skyld, er hele Unit1 her.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IEDownload, StdCtrls, UrlMon, wininet, ShellAPI, midaslib, MinUnits,
ExtCtrls;
type
TForm1 = class(TForm)
IEDownload1: TIEDownload;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure IEDownload1Complete(Sender: TBSCB; Stream: TStream; Result: HRESULT);
procedure IEDownload1Progress(Sender: TBSCB; ulProgress, ulProgressMax, ulStatusCode:
Cardinal; szStatusText: PWideChar; ElapsedTime, Speed, EstimatedTime: String);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetFileLastAccessTime(sFileName : string ) : TDateTime;
var
ffd : TWin32FindData;
dft : DWord;
lft : TFileTime;
h : THandle;
begin
h := Windows.FindFirstFile(PChar(sFileName), ffd);
if(INVALID_HANDLE_VALUE <> h)then
begin
FileTimeToLocalFileTime(ffd.ftLastAccessTime, lft );
FileTimeToDosDateTime(lft,LongRec(dft).Hi, LongRec(dft).Lo);
Result := FileDateToDateTime(dft);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
IEDownload1.go('http://www.sunwind.dk/designforum/downloadmap/murpro.zip','c:\\Bookmap\\murpro.zip');
end;
procedure TForm1.IEDownload1Complete(Sender: TBSCB; Stream: TStream;
Result: HRESULT);
begin
if (Result = S_OK) then
Memo1.lines.add('Download complete...')
else // Vil ikke gå videre, hvis filen eksisterer!
if DirectoryExists('c:\\bookmap\\murpro.zip') then begin
MessageDlg('c:\\bookmap\\murpro.zip var sidst opdateret den ' + TimeToStr(GetFileLastAccessTime( 'c:\\bookmap\\murpro.zip' ) ), mtInformation, [mbOk], 0 )
end;
end;
procedure TForm1.IEDownload1Progress(Sender: TBSCB; ulProgress,
ulProgressMax, ulStatusCode: Cardinal; szStatusText: PWideChar;
ElapsedTime, Speed, EstimatedTime: String);
var
s: string;
begin
s := BindstatusText(ulStatusCode);
if ulStatusCode = BINDSTATUS_DOWNLOADINGDATA then
s := S + ' (' + InttoStr(ulProgress) + '/' + InttoStr(ulProgressMax) + ')';
//memo1.lines.add(s);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Clear;
end;
end.
Med venlig hilsen Og et godt nytår.
Monie Jacobsen
energy@sunwind.dk