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 8659575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:02:49+00:00 2026-06-12T16:02:49+00:00

I have some inherited code for opening IE, this is short version : procedure

  • 0

I have some inherited code for opening IE, this is short version :

procedure OpenIE(URL: OleVariant; FieldValues: string = '');
var ie : IWebBrowser2;
begin
  ie := CreateOleObject('InternetExplorer.Application') as IWebBrowser2;
  ie.Navigate2(URL, Flags, TargetFrameName, PostData, Headers);
  ShowWindow(ie.HWND, SW_SHOWMAXIMIZED);
  ie.Visible := true;
  ...
end;

Since CreateOleObject takes a long time to execute I would like to have one “prepared” IE for the first run.

For example in Main FormCreate to call CreateOleObject, then for 1st call of OpenIE to use “IE” object already created.

For 2nd, 3rd … call of OpenIE – just usual call
ie := CreateOleObject

When I try to code it, I get some threads and marshaling errors, I am newbie in this area. What would be proper way to do this (some small code example would be great) ?

Thanks in advance.

  • 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-06-12T16:02:50+00:00Added an answer on June 12, 2026 at 4:02 pm

    Perhaps you are creating the browser instance in a different thread from which you then issue subsequent calls. The following trivial code works exactly as expected:

    type
      TMainForm = class(TForm)
        ShowBrowser: TButton;
        procedure FormCreate(Sender: TObject);
        procedure ShowBrowserClick(Sender: TObject);
      private
        FBrowser: Variant;
      end;
    
    procedure TMainForm.FormCreate(Sender: TObject);
    begin
      FBrowser := CreateOleObject('InternetExplorer.Application');
    end;
    
    procedure TMainForm.ShowBrowserClick(Sender: TObject);
    begin
      FBrowser.Navigate('http://stackoverflow.com');
      ShowWindow(FBrowser.HWND, SW_SHOWMAXIMIZED);
      FBrowser.Visible := True;
    end;
    

    I’m not using IWebBrowser2 because I don’t have the import unit handy. But that won’t change anything – your problems will not be related to early/late binding.

    Obviously FormCreate runs in the GUI thread. And ShowBrowserClick is a button OnClick event handler. And so it runs in the main GUI thread.

    If you are calling your OpenIE function from a thread other than the GUI thread, that would explain your errors. If you access the browser on a thread other than the one on which it was created, you will receive an EOleSysError with message The application called an interface that was marshalled for a different thread.

    Finally, a word of advice when asking questions. If you receive an error message, make sure you include that exact error message in your question. Doing so makes it much more likely we can provide good answers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some inherited JS code that uses this format: function main(param) { var
Hey, long story short I have inherited some terrible code. As a result a
I have inherited some C# code. This code needs to upload a picture to
I have inherited some code in which the previous coder wrote this: if (!not_null($page))
I have inherited some code. I see that this code exists: private List<int> Data
I just inherited some code, and have not seen this format before. Here's an
I have inherited some code: Process p = new ProcessBuilder(/bin/chmod, 777, path).start(); p.waitFor(); Basically,
I have inherited some code (from zip file) from a developer and git initialzed,
I have inherited some HTML code and have been asked to align the two
I have the following code in specman that I inherited: some_method() is { var

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.