Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:41:00+00:00 2026-05-14T07:41:00+00:00

I have a Delphi program that creates HTML files. Later when a button is

  • 0

I have a Delphi program that creates HTML files. Later when a button is pressed a TWebBrowser is created and a WebBrowser.Navigate causes the html page to display.

Is there anyway to set the WebBrowser “default directory” so it will always be the location of the Delphi executable not the HTML file?

I do not want to set the Base value in the HTML to a hardcoded value because then when the HTML is ran from another Delphi exe they are not found.

for example:

if the exe is run from D:\data\delphi\pgm.exe then the base location D:\data\delphi\ and the jpgs are at D:\data\delphi\jpgs\

but if the exe is run from: C:\stuff\pgm.exe i want the base location to be C:\stuff\ and the jpgs to be at C:\stuff\jpgs\

So I cannot write a line in the HTML with the base location since when it is ran from another exe it would point to wrong location for that exe.

So I either need to set the base location when I create the webbrowser and before I read the HTML or I need a way to pass into the webbrowser the location where I can then set the base location.

Sorry for being so long-winded but I could not figure out how to saw what I needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:41:00+00:00Added an answer on May 14, 2026 at 7:41 am

    Since TWebBrowser is just a wrapper around the Internet Explorer engine, there is an alternative you can try if you allow client-side scripting to be enabled in your browser.

    1. Create an Automation object in your
      app that implements the IDispatch
      interface, and give it a string
      property that returns the app’s
      current running path.
    2. Create an Automation object that
      implements the IDocHostUIHandler
      interface, and override its GetExternal()
      method to return a pointer to your
      object from #1.
    3. Retreive the browser’s ICustomDoc
      interface, and pass your IDocHostUIHandler
      object to its SetUIHandler() method.

    Refer to MSDN for more details:

    http://msdn.microsoft.com/en-us/library/aa770041.aspx

    This way, your HTML can contain scripting that can use the window.external object to retreive the app’s path and update its JPG references dynamically, such as in the OnLoad event, ie:

    <script language="JScript">
    function UpdateJPGs()
    {
      var path = window.external.ExePath;
      document.images.item("jpg1").src = path + "1.jpg";
      document.images.item("jpg2").src = path + "2.jpg";
      // etc...
    }
    </script>
    
    <body onLoad="UpdateJPGs">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 422k
  • Answers 422k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Elapsed time = total time to run the query (including… May 15, 2026 at 11:16 am
  • Editorial Team
    Editorial Team added an answer This is a 2D array. Possibly a sparse one if… May 15, 2026 at 11:16 am
  • Editorial Team
    Editorial Team added an answer It's available in the iPhone 4 SDK, so in Monotouch.… May 15, 2026 at 11:16 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.