windows - 为什么 WaitForSingleObject 会返回 WAIT_FAILED

标签 windows winapi mutex

MSDN 说

If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError.

代码是:

HANDLE     m_mutex_handle;    /**< m_mutex_handle. The handle to the created mutex. */
m_mutex_handle = ::CreateMutex( 0, false, NULL );
::WaitForSingleObject( m_mutex_handle, INFINITE );

但是可能发生的原因是什么?

最佳答案

如果您缺少对象的 SYNCHRONIZE 权限,那么您就等不及了。 WAIT_FAILED 将被返回。

关于windows - 为什么 WaitForSingleObject 会返回 WAIT_FAILED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/210751/

相关文章:

windows - 在 Windows 上模拟文件错误(例如 ERROR_ACCESS_DENIED)

c - 是否有必要使 pthread_mutex_t 变量可变?

c - 如何从程序集更改CPU频率(从Windows设备驱动程序)

c++ - win32主循环间隔问题C++

c++ - 获取 Windows API 标题栏图标

python - 多进程条件/命名锁

c++ - QMutex 是否需要是静态的,以便此类实例的其他线程调用知道暂停它们的操作?

python - 在 Windows 窄 Python 构建上识别宽 Unicode 点

windows - 创建虚拟文件夹并将它们挂接到文件系统

python - 从 Python 将密码传递给 runas