Solved

Find the default web browser

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
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…

810 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