1
111delphi
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么有的网页取不到文件大小? 下载不是页面的文件却可以得到大小.
有的却可以得到文件大小???
uses WinInet;
function GetWebPage(const Url: string):string;
var
Session,
HttpFile:HINTERNET;
szSizeBufferointer;
dwLengthSizeBufferWord;
dwReservedWord;
dwFileSizeWord;
dwBytesReadWord;
ContentsChar;
begin
Session:=InternetOpen('',0,niL,niL,0);
HttpFile:=InternetOpenUrl(Session,PChar(Url),niL,0,0,0);
dwLengthSizeBuffer:=1024;
HttpQueryInfo(HttpFile,5,szSizeBuffer,dwLengthSizeBuffer,dwReserved);
GetMem(Contents,dwFileSize);
InternetReadFile(HttpFile,Contents,dwFileSize,dwBytesRead);
InternetCloseHandle(HttpFile);
InternetCloseHandle(Session);
Result:=StrPas(Contents);
FreeMem(Contents);
有的却可以得到文件大小???
uses WinInet;
function GetWebPage(const Url: string):string;
var
Session,
HttpFile:HINTERNET;
szSizeBufferointer;
dwLengthSizeBufferWord;
dwReservedWord;
dwFileSizeWord;
dwBytesReadWord;
ContentsChar;
begin
Session:=InternetOpen('',0,niL,niL,0);
HttpFile:=InternetOpenUrl(Session,PChar(Url),niL,0,0,0);
dwLengthSizeBuffer:=1024;
HttpQueryInfo(HttpFile,5,szSizeBuffer,dwLengthSizeBuffer,dwReserved);
GetMem(Contents,dwFileSize);
InternetReadFile(HttpFile,Contents,dwFileSize,dwBytesRead);
InternetCloseHandle(HttpFile);
InternetCloseHandle(Session);
Result:=StrPas(Contents);
FreeMem(Contents);