Mirror

How can I check, whether the side in TWebbrowser is on local HD? (Views: 100)


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;

<< Back to main page