Solution EmbeddedWebBrowser website reported "Invalid floating point operation"

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

I have been using EmbeddedWebBrowser to do they use a browser, But found in enter some websites is a browser card dead or collapse, Then view the error found is the basic Flash.ocx Active controls to produce abnormal, Then throw the Invalid floating point operation error, To produce the wrong site basically are some video website, The most typical is Tencent video, For this unusual approach, Never found, Until recently to see the garden Eboy's blog this article

Then find a solution to the problem, in accordance with the above, I am in the main the form's Create event is added in the code:

Set8087CW(Longword($133f)); 

Compile and run the test problem is still!

It is in this way is the bluff? ? ?

My browser is created dynamically, will be the reason?? I also joined in the above code in browsing creates the event, after the test found that the problem is still, but suddenly think of Google search, so casually, found the:

function Get8087CW: Word; // for D5
asm
        PUSH    0
        FNSTCW  [ESP].Word
        POP     EAX
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer1.Enabled := False;
  Timer1.Interval := 5000; // 5 sec
  Saved8087CW := Get8087CW;
end;

procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
  const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);
begin
  Timer1.Enabled := False;
  System.Set8087CW($133F); // Disable all fpu exceptions
end;

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
   Timer1.Enabled := True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := False;
  Set8087CW(Saved8087CW);
end;

The answer, I immediately joined in the WebBrowser WebBrowser1BeforeNavigate2 event.

Set8087CW($133F); 

Not according to that method, magical things happen, this problem was solved.

Looked that, originally was forced to shut down the FPU floating point error

Subsequent tests also indicate that, this kind of close not completely, sometimes throws a Invalid floating point operation anomaly, but the issue has been resolved.!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Derek at January 07, 2014 - 3:54 AM