2009. február 24., kedd

How can I check, whether the side in TWebbrowser is on local HD?


Problem/Question/Abstract:

How can I check, whether the side in TWebbrowser is on local HD?

Answer:

// You need: A TWebbrowser, TButton, TLabel

procedure TForm1.Button1Click(Sender: TObject);
begin
  Webbrowser1.Navigate('file:///c:/test.txt');
end;

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  if Webbrowser1.Oleobject.Document.Location.Protocol = 'file:' then
  begin
    label1.Caption := 'The file is on a local drive!';
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése