MsgWaitForMultipleObjects仅在1709中抛出异常 [英] MsgWaitForMultipleObjects throwing exception only in 1709

查看:86
本文介绍了MsgWaitForMultipleObjects仅在1709中抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到1709后:如果在第二个参数中传递空值(对于句柄数组),MsgWaitForMultipleObjects调用将引发异常。 它在1709之前工作正常。 如果我在1709更改代码以传递数组它可以工作,但我们的用户使用的应用程序
大约10年,不想重新编译。 不知道为什么它在1709年突然停止工作。  msdn并不表示null无效。

After updating to 1709: MsgWaitForMultipleObjects call throws an exception if you pass a null in the second param (for the array of handles).  It works fine prior to 1709.  If I change the code to pass an array in 1709 it works but the application our users use is ~10 years old, prefer not to re-compile.  Not sure why it suddenly stopped working in 1709.  The msdn does not indicate a null is invalid.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms684242(v = vs.85)。 aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/ms684242(v=vs.85).aspx

猜测调用现在正在其他需要非空的地方进行调用?

Guessing the call is now being funneled somewhere else that requires a non null?

推荐答案

MSDN确实表明null无效。

MSDN does indicate that the null is invalid.

参数是:

_In_ const HANDLE *pHandles,

_In_表示参数是输入参数,因此它必须始终具有合法值。如果它可以处理null,那么我们会看到像

CreateEvent

The _In_ states that the parameter is an input parameter, therefore it must always have a legal value. If it could handle a null, then we would see things like from CreateEvent:

_In_opt_ LPCTSTR               lpName

_In_opt_参数类型声明它是一个可选的输入参数,这表明它可以有一个输入参数或是空的。您可以在
$ b中看到这一点$ b SAL文档,非常清楚。

The _In_opt_ parameter type states that it is an optional input parameter, this states that it can have an input parameter or be null. You can see this in the SAL documentation, and it is quite clear.

_In_定义为:

"注释作为标量的输入参数,结构,指向结构的指针等。明确地可以用在简单的标量上。参数必须在前置状态下有效且不会被修改。 "

"Annotates input parameters that are scalars, structures, pointers to structures and the like. Explicitly may be used on simple scalars. The parameter must be valid in pre-state and will not be modified. "

请注意"在状态前有效"?这意味着,对于指针,它必须指向有效对象,因此不能为null。

Note the "valid in pre-state"? This means that, for a pointer, it must point to a valid object, hence can't be null.

虽然_In_opt_没有明确的定义,但您可以将定义拼凑在一起通过定义_opt _:

While _In_opt_ doesn't have an explicit definition, you can piece the definition together by taking the definition of _opt_:

"当指针参数注释包含 _opt _ 时,它表示该参数可能为null。否则,注释执行的操作与不包含
_opt _ 的版本相同。"

"When a pointer parameter annotation includes _opt_, it indicates that the parameter may be null. Otherwise, the annotation performs the same as the version that doesn't include _opt_."

请注意,明确声明它可能为空。

Note that this explicitly states that it may be null.


这篇关于MsgWaitForMultipleObjects仅在1709中抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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