Witam
Napisałem sobie updater w oparciu o urlmon ale gdy wrzucę nowy plik to dopóki nie wyczyszczę historii IE to ściąga mi stary plik :/.
Istnieje możliwość wyłączenia cache?
PROBLEM ROZWIĄZANY!!
Wystarczy uzyc wininet
Witam
Napisałem sobie updater w oparciu o urlmon ale gdy wrzucę nowy plik to dopóki nie wyczyszczę historii IE to ściąga mi stary plik :/.
Istnieje możliwość wyłączenia cache?
PROBLEM ROZWIĄZANY!!
Wystarczy uzyc wininet
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, URLMon, ActiveX, ComCtrls, StdCtrls;
type
TDownload = class(TInterfacedObject, IBindStatusCallback)
protected
function OnStartBinding(dwReserved: DWORD; pib: IBinding): HResult; stdcall;
function GetPriority(out nPriority): HResult; stdcall;
function OnLowResource(reserved: DWORD): HResult; stdcall;
function OnProgress(ulProgress, ulProgressMax, ulStatusCode: ULONG;
szStatusText: LPCWSTR): HResult; stdcall;
function OnStopBinding(hresult: HResult; szError: LPCWSTR): HResult; stdcall;
function GetBindInfo(out grfBINDF: DWORD; var bindinfo: TBindInfo): HResult; stdcall;
function OnDataAvailable(grfBSCF: DWORD; dwSize: DWORD; formatetc: PFormatEtc;
stgmed: PStgMedium): HResult; stdcall;
function OnObjectAvailable(const iid: TGUID; punk: IUnknown): HResult; stdcall;
end;
TForm1 = class(TForm)
Button1: TButton; //wywolanie pobierania
Label1: TLabel; //pokazuje ile pobrano
ProgressBar1: TProgressBar; //progressbar
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
fDM: TDownload;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TDownload.GetBindInfo(out grfBINDF: DWORD;
var bindinfo: TBindInfo): HResult;
begin
grfBINDF := BINDF_ASYNCHRONOUS or BINDF_ASYNCSTORAGE or BINDF_DONTUSECACHE or
BINDF_NOWRITECACHE or BINDF_PRAGMA_NO_CACHE; //nocache
Result := S_OK;
end;
function TDownload.GetPriority(out nPriority): HResult;
begin
Result := S_OK;
end;
function TDownload.OnDataAvailable(grfBSCF, dwSize: DWORD;
formatetc: PFormatEtc; stgmed: PStgMedium): HResult;
begin
Result := S_OK;
end;
function TDownload.OnLowResource(reserved: DWORD): HResult;
begin
Result := S_OK;
end;
function TDownload.OnObjectAvailable(const iid: TGUID;
punk: IInterface): HResult;
begin
Result := S_OK;
end;
function TDownload.OnProgress(ulProgress, ulProgressMax,
ulStatusCode: ULONG; szStatusText: LPCWSTR): HResult; //obsługa paska postępu
var
p: Word;
begin
if ulProgressMax > 0 then
p:= Round(ulProgress / ulProgressMax * 100)
else
p:=0;
Form1.Label1.Caption:= Format('Pobrano %f MB z %f MB [%d %%]', [ulProgress / 1048576,
ulProgressMax / 1048576, p]);
Form1.ProgressBar1.Position:= ulProgress;
Form1.ProgressBar1.Max:= ulProgressMax;
Application.ProcessMessages;
Result := S_OK;
end;
function TDownload.OnStartBinding(dwReserved: DWORD; pib: IBinding): HResult;
begin
Result := S_OK;
end;
function TDownload.OnStopBinding(hresult: HResult; szError: LPCWSTR): HResult;
begin
Result := S_OK;
end;
procedure TForm1.Button1Click(Sender: TObject); //wywołanie pobierania
begin
fDM:= TDownload.Create;
URLDownloadToFile( nil, 'http://download.winzip.com/winzip145.exe',
'C:\winzip.exe', 0, fDM as IBindStatusCallback);
fDM:= nil;
end;
end.