Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

open IE

Posted on 2003-12-02
6
Medium Priority
?
207 Views
Last Modified: 2010-04-06
Hi all,

is there anybody know how I can add a button that can allow me to open an IE window ?

thanks a lot ;)
0
Comment
Question by:allie109
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 100 total points
ID: 9865138
This one can also open a new mail window....
uses Shellapi;
procedure TForm1.Button1Click(Sender: TObject);
type LinkType = (Internet, Email);
    Function OpenUrl(Method: LinkType; Url: string): Boolean;
    var LinkString: String;
    begin
        case Method of
            Internet: LinkSTring := 'http:\\'+Url;
            Email: LinkSTring := 'mailto:'+Url;
        end;
        result := ShellExecute(Hinstance,PChar('open'),PChar(LinkSTring),nil,nil,0) = Error_Success;
    end;
begin
   OpenUrl(Internet,'www.afsoftware.it');
   OpenUrl(Email,'ferruccio@afsoftware.it');
end;

F68 ;-)
0
 
LVL 1

Expert Comment

by:hush021299
ID: 9866421
{1.}

uses
  ShellAPI, Registry;

procedure OpenURL(Url: string);
var
  ts: string;
begin
  with TRegistry.Create do
    try
      rootkey := HKEY_CLASSES_ROOT;
      OpenKey('\htmlfile\shell\open\command', False);
      try
        ts := ReadString('');
      except
        ts := '';
      end;
      CloseKey;
    finally
      Free;
    end;
  if ts = '' then Exit;
  // remove quotes and commandline parameters
  ts := Copy(ts, Pos('"', ts) + 1, Length(ts));
  ts := Copy(ts, 1, Pos('"', ts) - 1);
  ShellExecute(0, 'open', PChar(ts), PChar(url), nil, SW_SHOW);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  OpenURL('http://www.hushpage.com);
end;


{2.}

{**************************************************************}
{ From: http://community.borland.com/article/0,1410,16858,00.html }

uses
  DdeMan,
{$IFDEF WIN32}
  Registry; {We will get it from the registry}
{$ELSE}
  IniFiles; {We will get it from the win.ini file}
{$ENDIF}

{$IFNDEF WIN32}
const  
  MAX_PATH = 144;
  {$ENDIF}

function GetProgramAssociation(Ext: string): string;
var
  {$IFDEF WIN32}
  reg: TRegistry;
  s: string;
  {$ELSE}
  WinIni: TIniFile;
  WinIniFileName: array[0..MAX_PATH] of Char;
  s: string;
  {$ENDIF}
begin
  {$IFDEF WIN32}
  s := '';
  reg := TRegistry.Create;
  reg.RootKey := HKEY_CLASSES_ROOT;
  if reg.OpenKey('.' + ext + '\shell\open\command',
    False) <> False then  
  begin
    {The open command has been found}
    s := reg.ReadString('');
    reg.CloseKey;
  end  
  else  
  begin
    {perhaps thier is a system file pointer}
    if reg.OpenKey('.' + ext,
      False) <> False then  
    begin
      s := reg.ReadString('');
      reg.CloseKey;
      if s <> '' then  
      begin
        {A system file pointer was found}
        if reg.OpenKey(s + '\shell\open\command',
          False) <> False then
          {The open command has been found}
          s := reg.ReadString('');
        reg.CloseKey;
      end;
    end;
  end;
  {Delete any command line, quotes and spaces}
  if Pos('%', s) > 0 then
    Delete(s, Pos('%', s), Length(s));
  if ((Length(s) > 0) and
    (s[1] = '"')) then
    Delete(s, 1, 1);
  if ((Length(s) > 0) and
    (Pos('"', s) > 0)) then
    Delete(s, Pos('"', s), Length(s));
  while ((Length(s) > 0) and
    (s[Length(s)] = #32)) do
    Delete(s, Length(s), 1);
  {$ELSE}
  GetWindowsDirectory(WinIniFileName, SizeOf(WinIniFileName));
  StrCat(WinIniFileName, '\win.ini');
  WinIni := TIniFile.Create(WinIniFileName);
  s  := WinIni.ReadString('Extensions',ext,'');
  WinIni.Free;
  {Delete any command line}
  if Pos(' ^', s) > 0 then
    Delete(s, Pos(' ^', s), Length(s));
  {$ENDIF}
  Result := s;
end;

procedure StartNewBrowserWindow(URL: string);
var
  DDEConv: TDDEClientConv;
  URLFired: bool;
  App: string;
  UpApp: string;
  p: array[0..MAX_PATH] of Char;
begin
  UrlFired := False;
  App := GetProgramAssociation('HTM');
  UpApp := Uppercase(App);
  Delete(App, Pos('.EXE', UpAPP), Length(App));
  if Pos('NETSCAPE.EXE',
    UpApp) > 0 then  
  begin
    DDEConv := TDDEClientConv.Create(nil);
    DDEConv.ServiceApplication := App;
    if DDEConv.SetLink('NETSCAPE', 'WWW_OpenURL') then
      if DDEConv.RequestData(URL + ',,0x0,0x0') <> nil then
        if DDEConv.SetLink('NETSCAPE', 'WWW_Activate') then
          URLFired := DDEConv.RequestData('0xFFFFFFFF,0x0') <> nil;
    DDEConv.Free;
  end  
  else if Pos('IEXPLORE.EXE',
    UpApp) > 0 then  
  begin
    DDEConv := TDDEClientConv.Create(nil);
    DDEConv.ServiceApplication := App;
    if DDEConv.SetLink('iexplore', 'WWW_OpenURL') then
      if DDEConv.RequestData(URL + ',,0') <> nil then
        if DDEConv.SetLink('iexplore', 'WWW_Activate') then
          URLFired := DDEConv.RequestData('0,0') <> nil;
    DDEConv.Free;
  end;
  if UrlFired = False then
    WinExec(StrPCopy(@p, URL), SW_SHOWNORMAL);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  StartNewBrowserWindow('http://www.borland.com');
  StartNewBrowserWindow('http://www.yahoo.com');
end;

**************************************************
or simply
uses
  ShellApi;

{....}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShellExecute(Handle,
               'open',
               'http://www.www.hushpage.com',
               nil,
               nil,
               SW_SHOW);
end;

0
 
LVL 2

Expert Comment

by:TheLeader
ID: 9872716
uses shellapi;

Procedure open_IE(IE_address: String);
Begin
ShellExecute(0,'open',IE_address,nil,nil,SW_SHOW);
end;

{you can replace SW_SHOW with
SW_HIDE,SW_SHOW,SW_MINIZE,SW_MAXIMIZED,SW_SHOWNORMAL}

//call the procedure
ex:
procedure TForm1.Button1Click(Sender: TObject);
begin
   open_IE('http://www.yahoo.com');
end;

hope it helped ...
0
 
LVL 1

Expert Comment

by:fidel83
ID: 9880429
if you just want internet explorer then:

//at the top:
uses shellApi;

shellExecute(0, 'open', PChar('iexplore.exe'), nil, nil, SW_SHOWNORMAL);
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 12382280
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: Ferruccio68

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Karamja (Alan)
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

670 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