Solved

Find the default web browser

Posted on 1997-08-27
4
169 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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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