Recent

Author Topic: GetActiveOleObject fails even though CreateOleObject succeeds  (Read 1392 times)

RedOctober

  • Sr. Member
  • ****
  • Posts: 414
GetActiveOleObject fails even though CreateOleObject succeeds
« on: August 30, 2021, 03:11:21 pm »
Can some one explain what I am doing wrong?  After I successfully open IE from Lazarus, then I try to access it again later in code, I will get a "RPC server unavailable" error message.  In an attempt to overcome that error, I decided to try and "find" the Ole object by using GetActiveOleObject().  But that fails too... even immediately after the successful creation of the Ole object.

Code: Pascal  [Select][+][-]
  1.  
  2. uses  ... Windows, ComObj;
  3. ...
  4. Browser := CreateOleObject('InternetExplorer.Application');  // <--- this line succeeds
  5. Browser := GetActiveOleObject('InternetExplorer.Application');  // <--- this line fails
  6. ...
  7.  
  8.  

Error displayed:
Operation unavailable.
« Last Edit: August 30, 2021, 06:12:33 pm by RedOctober »

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1053
Re: GetActiveOleObject fails even though CreateOleObject succeeds
« Reply #1 on: August 30, 2021, 04:43:51 pm »
hello,
may be a problem with the internet explorer com object. 
With ms Word i have no problem with this code :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. var msWord,sourDoc : OleVariant;
  3. begin
  4. msWord := CreateOleObject('Word.Application');
  5. msWord := GetActiveOleObject('Word.Application');
  6. sourDoc := msWord.Documents.Open('d:\temp\monDoc.doc');
  7. msWord.Visible := true;
  8. end;
maybe it is time to use other thing that internet explorer (end of life).  See this message

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

loaded

  • Sr. Member
  • ****
  • Posts: 299
Re: GetActiveOleObject fails even though CreateOleObject succeeds
« Reply #2 on: September 09, 2021, 10:44:53 am »
may be a problem with the internet explorer com object. 
No problem, this is a precaution taken for security reasons.
You cannot connect to a session opened in Internet Explorer for security reasons, you can only access the session you started.
Lazarus V2.0.10 32 Bit + Intel I5 8250U + 12GB RAM + Win 10 Home 64 Bit = red pill
Morpheus: "You take the blue pill...the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill...you stay in Wonderland, and I show you how deep the rabbit hole goes."

 

TinyPortal © 2005-2018