Solved

Communication between Delphi Application and the Default Web Browser

Posted on 2004-08-25
6
401 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
A short film showing how OnPage and Connectwise integration works.

914 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

19 Experts available now in Live!

Get 1:1 Help Now