Win32注册表线程安全吗? [英] Is the Win32 registry thread-safe?

查看:58
本文介绍了Win32注册表线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有两个进程访问给定的注册表项(例如HKLM),我应该将逻辑包装在互斥锁中吗?

If I have two processes accessing a given registry key (e.g. HKLM), should I wrap the the logic in a mutex?

推荐答案

注册表将确保操作是原子的,因此您不必自己进行同步.

The registry will make sure the actions are atomic, so you don't have to synchronize it yourself.

但是,如果您有多个进程/线程同时访问注册表,则不能保证先发生哪个事件.只是您不会得到乱码的数据.

However, if you have multiple processes / threads accessing the registry at the same time, it doesn't make any guarantees about which happens first. Only that you won't get garbled data.

进一步阅读,请参见无法将某人拒之门外注册表是一个功能,而不是一个错误.

这篇关于Win32注册表线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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