• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 450
  • Last Modified:

Communication between Delphi Application and the Default Web Browser

Hello Experts,

How does a Delphi application communicate with the Default web browser? Let me explain the scenario. I use TIdHTTP from the Delphi app to submit variables to a PHP script called "test.php" located in 'http://anywhere/", which in turn dynamically creates the HTML code for display of a web page. This part works fine. Now the jackpot question: How do I open the DEFAULT WEB BROWSER (IE , Netscape, Opera, whatever) with the web page dynamically created by test.php? I cannot use the TWebBrowser component because it only caters for IE and therefore eliminates users with any other web browser besides IE. I have a feeling that ShellAPI or something similar could be used for this, but it probably wouldn't be straightforward. If ShellAPI is somehow the answer, I would need some example code to see the syntax.

Can anybody help?
0
JDJVR
Asked:
JDJVR
2 Solutions
 
Ivanov_GCommented:
save the HTML generated by test.php to TEMP file and open in default web browser using ShellExecute...
0
 
BaTy_GiRlCommented:

add to uses list ShellAPI

First you need to find out where is the path of you Iexplorer, or netscape my path is in Program Files

then the syntax of shell execute is


if ShellExecute(Self.Handle, nil, 'C:\Program Files\Internet Explorer\IEXPLORE.EXE','C:\readme.htm', nil, SW_SHOWMAXIMIZED) <= 32 then
    Application.MessageBox('Couldn''t execute the application','Error', MB_ICONEXCLAMATION);

where  the C:\readme.html is the file i want to open, if you want to open a file from http, just quit the C:\

Best Wishes
   B@ty



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.

 
JDJVRAuthor Commented:
Thanks - the TEMP file solution should work, but is there any way to avoid having to save a TEMP file and still use ShellExecute?
0
 
Lee_NoverCommented:
I'd setup a HTTP server in my app (just add a TIdHTTPServer compo and set a "random" port)
get the php returned page, save it (in memory) then ShellExecute with the url having the ID of this page like: 'http://localhost:someport/?id=someid'
in the request handler of the http server just check for the id and stream the result back :)

avoiding saving to a file but will have to provide an open port
don't see any other alternatives (yet)

:)
0
 
JDJVRAuthor Commented:
Thank you, everybody. I think I will be able to do what I need to with the feedback you have given me. I'll split the points between Ivanov G and Lee Nover. I have another question which is about communication from the web page back to the Delphi app via PHP (I think I may have an idea how to do it) but I will post it as a separate question later if needed.

Cheers!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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