Solved

Communication between Delphi Application and the Default Web Browser

Posted on 2004-08-25
6
411 Views
Last Modified: 2010-04-05
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
Comment
Question by:JDJVR
6 Comments
 
LVL 12

Assisted Solution

by:Ivanov_G
Ivanov_G earned 100 total points
ID: 11892634
save the HTML generated by test.php to TEMP file and open in default web browser using ShellExecute...
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11892656
0
 

Expert Comment

by:BaTy_GiRl
ID: 11893253

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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:JDJVR
ID: 11897489
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
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 100 total points
ID: 11899891
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
 

Author Comment

by:JDJVR
ID: 11900166
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

838 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