?
Solved

How to detect if internet and a browser is installed?

Posted on 1998-06-19
5
Medium Priority
?
192 Views
Last Modified: 2010-04-04
I write at a program in Delphi 3 that will use a TLABEL as link to a website. It gets the ONCLICK-Event and should start the browser with the URL defined in .CAPTION. I know that IE4 can connect to an URL given thru the command line as parameter. But first, how would i check, if IE or NS or any other browser and a internet-access software is installed on the computer that runs my program on :)

thx, Omsec
0
Comment
Question by:omsec
[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
5 Comments
 
LVL 10

Expert Comment

by:Jacco
ID: 1354100
You can try

ShellExecute('http:\\www.microsoft.com');

this way you execute a URL

Internet explorer is started automatically

No command line needed.

To determine wether IE is installed you can check the proper registryentries !
0
 
LVL 2

Author Comment

by:omsec
ID: 1354101
do I have to include a special (Active-X) Control/Unit ?
0
 

Expert Comment

by:dskowron
ID: 1354102
Delphi 3 includes native controls for web programming so there would be no need for any Active X or other outside control. However, the comment made by Jacco is correct - you just execute the url. The "HTM" or "HTML" file extension would be registered to be handled by the user's browser. If none existed, you could trap that error. Actually, in that case, you could launch a simple browser that you write in Delphi 3.
0
 
LVL 2

Author Comment

by:omsec
ID: 1354103
ShellExecute('http:\\www.microsoft.com'); does not work
0
 
LVL 6

Accepted Solution

by:
Holger101497 earned 200 total points
ID: 1354104
I'm afraid it is a little more complicated than this....
Try to take a look at the Delphi FAQ at http://www.inprise.com/devsupport/delphi/qanda/#9

This is for How to launch web site in default browser:

Frequently Asked Questions

                       Displaying documents in the default browser

                       Question:

                       How can I start the default browser with an URL in a new browser window?

                       Answer:

                       The following example attempts to start the specified URL
                       in a new browser window. Note: Not all versions of
                       Internet Explorer will respond with a new window.

                       Example:

                       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;

I've used it and it works... I now just saw this other FAQ:
Launching a web browser

                       Question:

                       How can I launch the computer's current web brower with a specific web site URL?

                       Answer:

                       Call the Win32 API function called HlinkNavigateString which is
                       declared in the UrlMon unit.

                       Example call:

                         HlinkNavigateString(Nil,'http://www.borland.com');

                       If you're calling this from an ActiveForm then call it like this:

                         HlinkNavigateString(ComObject,'http://www.borland.com');

Seems a lot simpler, but I don't know exactly what it does. Also, the first example gives you a lot more information...
Good luck!!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 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