Solved

Running a TWebBrowser program *without* IE 4 or better

Posted on 2002-05-24
5
143 Views
Last Modified: 2010-04-04
Hi,

I have an application written in Delphi 4 Pro and on the main form I have a TWebBrowser ActiveX control that is created dynamically in FormCreate.  Now I understand that TWebBrowser requires a minimum of IE 4 to operate correctly.  So, what would happen if the end user runs my deployed program on a computer that has an old version of IE (less than 4, or even doesn't have IE installed at all)?  Will the program crash?  Will it display an error message (if so what and is the message meaningful to the end user?)?  Will the program exit gracefully?

What is the best way to handle this situation?  Ideally, I would like do display a meaningful error message if IE 4 or better isn't installed and exit gracefully.  I could add some code to check, but I think that Delphi might not even get as far as running the code to check that IE 4 or better isn't installed on the target PC(?).

Best Regards,

Richard
0
Comment
Question by:Richard2000
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Russell Libby
ID: 7033022

Richard,

The best way to handle this is to wrap the web browser control creation in a try...except handler. That way if it bombs, you can get control, display the message you want, and exit gracefully.

Russell
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7034022
Take a look at http://www.euromind.com/iedelphi for EmbeddedWb component . And not only :)

0
 

Author Comment

by:Richard2000
ID: 7037461
Hi,

Thanks for your comments.  My program requires a minimum version of IE 4 for 2 reasons...

1) It uses the TWebBrowser control.
2) It uses Russell's TDownloader component that uses the asynchronous WinInet.

I'm creating all TWebBrowser and TDownloader components dynamically to give me more control.  What I had planned to do originally was test the IE version at the start in FormCreate and if IE 4 or better isn't installed, display a user-friendly error message and close down the program before any TWebBrowser or TDownloader instances are created.

The problem is that when I try to run the program on a PC that doesn't have IE 4 or better installed, Delphi doesn't seem to run the program at all - it just seems to display it's own error messages.  No code seems to be executed at all under this circumstance, so it is difficult to display a user defined message.  Using try..except blocks would not make any difference, because the code is never executed.

I have an old PC running Windows '95 with Plus! installed.  It has a very old version of IE on it.  When I run the EXE, I get 2 error messages...

1st Message

A:\Test.exe (Title)

A:\Test.exe

A device attached to the system is not functioning.

2nd Message

Error Starting Program (Title)

The TEST.EXE file is linked to missing export WININET.DLL:InternetGetConnectedState

So it never gets as far as executing the code to determine if IE 4 or better is installed.  I was hoping to be able to detect this and display a more user-friendly message such as "Sorry, Internet Explorer 4 or better is required to use this program.".  Is there any way to do this?

Of course, if I run the program on a PC with IE 4 or better installed, everything works perfectly.  I've tried the TDownloader component a lot and it works wonders (all of the changes you made last to the component seems to work fine too) - thanks Russell!

Richard
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 50 total points
ID: 7039224

Richard,

1.) Have you tried putting the try..except blocks in the program source (dpr file)?

Ex:

begin
   try
     Application.Initialize;
     Application.CreateForm(TForm1, Form1);
     Application.Run;
  except
    on E: Exception do
    begin
      // Display your error message
    end;
  end;
end;

2.) If your still unable to catch any errors, you could:
Write a small stub program that does the compatiblity checking. The user would run this program, and providing that all requirements were met, the stub program would launch your program.


Just some suggestions. Perhaps others can offer some more input to come up with a solution that works for you.

Russell
0
 

Author Comment

by:Richard2000
ID: 7056343
Hi Russell,

Many thanks for your comment.

I tried your first suggestion.  I put just a TWebBrowser on a form and put the exception handler in the dpr and it did display a custom error message when it was run on a computer without IE 4 or better installed.  However, when I added the TDownloader component I still got Delphi's own error message and it doesn't seem that in this circumstance the try..except code had any effect.  I assume that when it realises it is missing a dependent file, Delphi just displays its own error message and doesn't run any code itself.

The stub idea is an interesting one and I'll give that a try.  Although it might not be worth the extra overhead for the advantage gained (especially as virtually all PCs now have IE 4 or better installed).

Richard
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now