Solved

Find the default web browser

Posted on 1997-08-27
4
167 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

12 Experts available now in Live!

Get 1:1 Help Now