Solved

Find the default web browser

Posted on 1997-08-27
4
166 Views
Last Modified: 2010-04-06
How do I open the default web browser, with a given URL, at run-time on the users machine.
0
Comment
Question by:essbb
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:itamar
ID: 1342638
Increase the points to 100 and i'll give you an answer with the complete code.
0
 

Author Comment

by:essbb
ID: 1342639
Fine
0
 
LVL 4

Accepted Solution

by:
itamar earned 100 total points
ID: 1342640
Here goes the D2 source-code. Just copy, paste and run ! (Please, think about increasing points if you like this ;)

>>>>>>>>>>>

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    btnGO: TButton;
    edtURL: TEdit;
        procedure btnGOClick(Sender: TObject);
        procedure ExecuteFile(Command, Params, WorkDir:string);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ExecuteFile(Command, Params, WorkDir:string);
var aux : integer;
begin
      { convert Pascal string to Null-termintated strings }
      Command := Command + #0;
      Params := Params + #0;
      WorkDir := WorkDir + #0;
      { run/open application/file }
      aux := ShellExecute(Self.Handle,'Open',@Command[1],
                                     @Params[1], @WorkDir[1], SW_SHOWNORMAL);
      if aux < 32 Then
        MessageDlg('Could not execute ' + Command,mtError,[mbOK],0);
end;

procedure TForm1.btnGOClick(Sender: TObject);
begin
      If edtURL.Text <> '' Then
            ExecuteFile('http://' + edtURL.Text,'','');
end;

end.


0
 

Author Comment

by:essbb
ID: 1342641
Thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now