Opening a page in default browser.

Without any extra components other than a button, how do I open a website in the user's default browser?
MAXcomAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
like this:

add to uses section "shellapi"
then on button click do:

ShellExecute(Application.Handle,'open','c:\some.html',nil,nil,SW_SHOWNORMAL);

Regards Barry
0
 
intheCommented:
just change the 'c:\some.html' to
'http:\\www.experts-exchange.com'
0
 
intheCommented:
so your unit look like this:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,Shellapi;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(Application.Handle,'open','Http:\\www.experts-exchange.com',nil,nil,SW_SHOWNORMAL);
end;

end.

0
All Courses

From novice to tech pro — start learning today.