Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Find the default web browser

How do I open the default web browser, with a given URL, at run-time on the users machine.
0
essbb
Asked:
essbb
  • 2
  • 2
1 Solution
 
itamarCommented:
Increase the points to 100 and i'll give you an answer with the complete code.
0
 
essbbAuthor Commented:
Fine
0
 
itamarCommented:
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
 
essbbAuthor Commented:
Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now