?
Solved

Opening URLS

Posted on 2005-04-21
8
Medium Priority
?
290 Views
Last Modified: 2010-04-05
Having a few problems in regards to opening URLS in NEW windows.

I have tried several different methods of opening urls, all of which open new webbrowser windows when using firefox, but not in internet explorer. Below is an example of one method i have tried.

ShellExecute(self.WindowHandle,'open','www.google.com',nil,nil, SW_SHOWNORMAL);

When called, this opens google in a new firefox window for me, however a friend is using internet explorer, and this code simply redirects his active internet explorer window to the desired url. Is there a simple way of stopping this from happening, opening a new instance on IE instead?
Perhaps there is another way of doing this instead?

Any help is kindly appreciated.
Regards
GreenAndroid
0
Comment
Question by:Greenandroid
  • 3
  • 3
  • 2
8 Comments
 
LVL 15

Accepted Solution

by:
mikelittlewood earned 200 total points
ID: 13834824
ShellExecute(0, 'open', 'Iexplore.exe', 'http:\\www.google.com', nil, SW_SHOWNormal);
0
 
LVL 13

Expert Comment

by:Ashok
ID: 13834891
include shellAPI in uses

private
  procedure BrowseTo(sURL, sBrowser, SDir : String);
public
end;

var
  Form1: TForm;
  sei : TShellExecuteInfo;
.
.
.  
procedure TForm1.BrowseTo(sURL, sBrowser, SDir : String);
begin
  ZeroMemory(@sei, sizeof(sei));
  with sei do
  begin
    cbSize := SizeOf(sei);
    fmask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := Form1.Handle;
    lbVerb := 'open';
    if sBrowser <> #0 then
        lpFile := PChar(sBrowser)
    else
        lpFile := PChar(sURL);
    lpParameter := PChar(sURL);
    lpDirectory := PChar(sDir);
    nShow := SW_SHOWNORMAL;
  end;
  ShellExecuteEx(@sei);
end;

HTH
Ashok
0
 
LVL 13

Expert Comment

by:Ashok
ID: 13834964
in ButtonClick

  BrowseTo('http://www.google.com', 'Iexplore.exe',  #0);

in Last Parameter try with #0
if it does not work
then
supply with Path info for Iexplore.exe file.

HTH
Ashok
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Author Comment

by:Greenandroid
ID: 13835235
Hmm,

Well these codes may work fine opening new IE windows, but perhaps you have slightly misunderstood my question. I need the code to open the url in the persons default browser.
 
The code i have included in my original post is a typical example of this. It opens the users default browser, and navigates to the desired url, but has problems with IE. In any other browser i have tried it with, it opens up a new instance, whereas in IE it redirects the current active IE window.

In other words, if a users default browser is set as internet explorer, it redirects the current IE window to the desired url, rather than opening up a new instance, which i need it to.

Perhaps the easiest solution would be to detect if their default browser is IE, and if so, using the code mikelittlewood added.

Any other thoughts?
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13835415
Yeah my code will always open in a new IE browser .. as long as IE is actually on the PC. Mine won't use a default browser but always IE.
If you can work out through code what their default browser is and grab the path to the browser then you can just replace the call to IE in my code with the path to the browser they are using. This should then open up in a new window regardless.
0
 
LVL 2

Author Comment

by:Greenandroid
ID: 13835546
Well i tested your code on my computor, and it worked nicely with ie, and i have got it to detect the default browser and run the appropiate procedure if it detects ie or another browser.... but starting to think the  problem with new ie windows may be more localised on my friends computor.

I compiled a demo project and sent it to him, and it detected he was running ie nicely. Upon trying to open google.com with your code, again, it redirected his current ie window. I will keep this post open for a little longer, to see if i get any other possibe sollutions, and also gives me time to test the code on other workstations.

Thanks
Green
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13835919
hmm .. I wonder if something small like folder options for general windows exporer might be affecting it.
Other than that Im not sure what else might be causing it to open in the current IE window Im afraid.
0
 
LVL 2

Author Comment

by:Greenandroid
ID: 13839405
Well i have fixed the problems, and found a small bug in my original coding. The whole thing works nicely now, with my project detecting the default browser and taking the appropiate action.

Points awarded to mikelittlewood.Ty

Regards
Green
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

749 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