1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78:
| uses ActiveX, WinInet;
function DownloadURL_NOCache(const aUrl: string; var s: string): Boolean; var hSession: HINTERNET; hService: HINTERNET; lpBuffer: array[0..1024 + 1] of Char; dwBytesRead: DWORD; begin Result := False; s := ''; hSession := InternetOpen(PChar(Application.ExeName), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try if Assigned(hSession) then begin hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, INTERNET_FLAG_RELOAD, 0); if Assigned(hService) then try while True do begin dwBytesRead := 1024; InternetReadFile(hService, @lpBuffer, 1024, dwBytesRead); if dwBytesRead = 0 then Break; lpBuffer[dwBytesRead] := #0; s := s + lpBuffer; end; Result := True; finally InternetCloseHandle(hService); end; end; finally InternetCloseHandle(hSession); end; end;
procedure WB_LoadHTML(WebBrowser: TWebBrowser; HTMLCode: string); var sl: TStringList; ms: TMemoryStream; begin WebBrowser.Navigate('about:blank'); while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do Application.ProcessMessages;
if Assigned(WebBrowser.Document) then begin sl := TStringList.Create; try ms := TMemoryStream.Create; try sl.Text := HTMLCode; sl.SaveToStream(ms); ms.Seek(0, 0); (WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms)); finally ms.Free; end; finally sl.Free; end; end; end;
procedure TForm1.Button1Click(Sender: TObject); const URL = 'http://www.sensor-systems.com/biggraphic.html'; FILTER_IMG = '<img src="images/2000rgb.jpg" width="1772" height="1338">'; var htmlCode: string; begin if DownloadURL_NOCache(URL, htmlCode) then htmlCode := StringReplace(htmlCode, FILTER_IMG, '', []); WB_LoadHTML(Webbrowser1, htmlCode); end; |