Delphi XE2,TWebBrowser,浮点除以零 [英] Delphi XE2, TWebBrowser, float divide by zero

查看:233
本文介绍了Delphi XE2,TWebBrowser,浮点除以零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Delphi 2010和Delphi 2007中,我在WebBrowserBeforeNavigate / WebBrowserDocumentComplete上使用Set8087CW来防止ActiveX中的FPU错误瘫痪我的应用程序。

In Delphi 2010 and Delphi 2007 I am using Set8087CW on WebBrowserBeforeNavigate / WebBrowserDocumentComplete to prevent FPU errors inside ActiveX to cripple my application.

但不知何故,这不工作Delphi XE2,至少在64位模式下。

But somehow this is not working in Delphi XE2, at least when in 64bit mode.

当点击链接(任何)我得到浮动除以零。 (网站地址或内容到TWebBrowser的初始加载工作正常。)

When clicking links (any) I get "float divide by zero". (The initial loading of a website address or content into TWebBrowser works fine.)

callstack显示在system32 \D3D10Warp.dll内发生(可能被IE9使用) )响应TApplication.ProcessMessage(和一些???在两者之间)

The callstack shows this to happen inside system32\D3D10Warp.dll (maybe used by IE9?) in response to TApplication.ProcessMessage (and some ??? inbetween the two)

推荐答案

您将需要屏蔽SSE异常64位,因为64位代码通常使用SSE来执行浮点运算。

You will need to mask SSE exceptions on 64 bit because 64 bit code typically uses SSE to perform floating point arithmetic.

调用 SetMXCSR 更改SSE单元的控制状态。就个人而言,我将继续掩盖8087个例外,因为64位代码完全可以自由地使用8087单元,如果它愿意的话。调用Web浏览器代码时要使用的魔术MXCSR值为 $ 1F80 。这是MXCSR的默认Windows值。

Call SetMXCSR to change the control state of the SSE unit. Personally I would continue masking 8087 exceptions since 64 bit code is perfectly at liberty to use the 8087 unit should it so wish. The magic MXCSR value that you want to use when calling the web browser code is $1F80. This is the default Windows value for MXCSR.

或者,您可以调用 SetSSEExceptionMask SetFPUExceptionMask 通过 exAllArithmeticExceptions 来屏蔽所有异常。这些方便的方法将使您的代码更易于阅读。

Alternatively, you can call SetSSEExceptionMask and SetFPUExceptionMask passing exAllArithmeticExceptions to mask all exceptions. These convenience methods would make your code more readable.

如果您确信只需要在x86和x64下的8087上屏蔽例外,那么您只需调用< a href =http://docwiki.embarcadero.com/VCL/en/Math.SetExceptionMask =noreferrer> SetExceptionMask 。这将改变x86下的8087控制状态,并更改x64下的SSE控制状态。

If you are satisfied that you only need to mask exceptions on 8087 under x86 and SSE under x64 then you can just call SetExceptionMask. This will change the 8087 control state under x86 and change the SSE control state under x64.

如果我必须在设置整个控制状态或使用方便方法之间进行选择改变只是异常屏蔽部分的状态,我将设置整个控制状态。这些ActiveX控件是在假设您将使用MS工具并预期特定的FP控制状态的情况下编写的。我会给这些控件确定他们期望的控制状态,然后在从控件执行返回时恢复到Delphi控件状态。

If I had to choose between setting the entire control state or using the convenience methods to change just the exception masking part of the state, I would set the entire control state. These ActiveX controls are written under the assumption that you will be using MS tooling and expect a specific FP control state. I would give these controls the exact control state that they expect and then revert back to the Delphi control state when execution returns from the controls.

这篇关于Delphi XE2,TWebBrowser,浮点除以零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆