Lazarus

Programming => Networking and Web Programming => Topic started by: RedOctober on August 30, 2021, 03:11:21 pm

Title: GetActiveOleObject fails even though CreateOleObject succeeds
Post by: RedOctober 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.
Title: Re: GetActiveOleObject fails even though CreateOleObject succeeds
Post by: Jurassic Pork 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 (https://forum.lazarus.freepascal.org/index.php/topic,56034.msg416568.html#msg416568)

Friendly, J.P
Title: Re: GetActiveOleObject fails even though CreateOleObject succeeds
Post by: loaded 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.
TinyPortal © 2005-2018