828
社区成员
发帖
与我相关
我的任务
分享
unit xURLDOWNLOAD;
{为了拆一个函数得用这么多...}
interface
uses Windows ;
type
PDVTargetDevice = ^TDVTargetDevice;
tagDVTARGETDEVICE = record
tdSize: Longint;
tdDriverNameOffset: Word;
tdDeviceNameOffset: Word;
tdPortNameOffset: Word;
tdExtDevmodeOffset: Word;
tdData: record end;
end;
TDVTargetDevice = tagDVTARGETDEVICE;
PClipFormat = ^TClipFormat;
TClipFormat = Word;
PFormatEtc = ^TFormatEtc;
tagFORMATETC = record
cfFormat: TClipFormat;
ptd: PDVTargetDevice;
dwAspect: Longint;
lindex: Longint;
tymed: Longint;
end;
TFormatEtc = tagFORMATETC;
POleStr = PWideChar;
PGUID = ^TGUID;
TGUID = packed record
D1: LongWord;
D2: Word;
D3: Word;
D4: array[0..7] of Byte;
end;
TCLSID = TGUID;
PStgMedium = ^TStgMedium;
{$EXTERNALSYM tagSTGMEDIUM}
tagSTGMEDIUM = record
tymed: Longint;
case Integer of
0: (hBitmap: HBitmap; unkForRelease: Pointer{IUnknown});
1: (hMetaFilePict: THandle);
2: (hEnhMetaFile: THandle);
3: (hGlobal: HGlobal);
4: (lpszFileName: POleStr);
5: (stm: Pointer{IStream});
6: (stg: Pointer{IStorage});
end;
TStgMedium = tagSTGMEDIUM;
PBindInfo = ^TBindInfo;
_tagBINDINFO = packed record
cbSize: ULONG;
szExtraInfo: LPWSTR;
stgmedData: TStgMedium;
grfBindInfoF: DWORD;
dwBindVerb: DWORD;
szCustomVerb: LPWSTR;
cbstgmedData: DWORD;
dwOptions: DWORD;
dwOptionsFlags: DWORD;
dwCodePage: DWORD;
securityAttributes: TSecurityAttributes;
iid: TGUID;
pUnk: IUnknown;
dwReserved: DWORD;
end;
TBindInfo = _tagBINDINFO;
IBinding = interface
['{79eac9c0-baf9-11ce-8c82-00aa004ba90b}']
function Abort: HResult; stdcall;
function Suspend: HResult; stdcall;
function Resume: HResult; stdcall;
function SetPriority(nPriority: Longint): HResult; stdcall;
function GetPriority(out nPriority: Longint): HResult; stdcall;
function GetBindResult(out clsidProtocol: TCLSID; out dwResult: DWORD;
out szResult: POLEStr; dwReserved: DWORD): HResult; stdcall;
end;
IBindStatusCallback = interface
['{79eac9c1-baf9-11ce-8c82-00aa004ba90b}']
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;
function URLDownloadToFile(Caller: IUnknown; URL: PChar; FileName: PChar; Reserved: DWORD; StatusCB: IBindStatusCallback): HResult; stdcall;
function wwDownLoad(URL: PChar ;Filename: PChar) : Boolean;
implementation
function URLDownloadToFile;external 'URLMON.DLL' name 'URLDownloadToFileA';
function wwDownLoad(URL: Pchar ;Filename: Pchar) :Boolean;
begin
Result := (UrlDownloadToFile(nil, PChar(URL), PChar(Filename), 0, nil) = 0);
end;
end.