...
首页> 外文期刊>MSDN Magazine >Use Modern C++ to Access the Windows Registry
【24h】

Use Modern C++ to Access the Windows Registry

机译:使用现代C ++访问Windows注册表

获取原文
获取原文并翻译 | 示例
   

获取外文期刊封面封底 >>

       

摘要

The Windows OS exposes a series of C-interface APIs to give developers access to the registry. Some of these APIs are fairly low level and require programmers to pay attention to many details. Starting with Windows Vista, a kind of higher-level API was added to the mix: the RegGetValue function (bit.ly/2jXtfpJ). Before this API was introduced, to read a value from the registry, you first had to open the desired registry key containing the value calling RegOpenKeyEx. Then, you had to call the RegQueryValueEx API, dealing with many complex details. For example, if you read a string value with RegQueryValueEx, the returned string is not guaranteed to be properly NUL-terminated, which can cause a series of dangerous security bugs in your code. To prevent that from happening, you have to pay attention to check if there's a NUL terminator in the returned string; if there isn't any, you have to add it. Moreover, you have to make sure you properly close the open key, calling RegCloseKey.
机译:Windows操作系统公开了一系列C接口API,使开发人员可以访问注册表。其中一些API的级别很低,需要程序员注意许多细节。从Windows Vista开始,将一种更高级别的API添加到了组合中:RegGetValue函数(bit.ly/2jXtfpJ)。在引入此API之前,要从注册表中读取值,您首先必须打开所需的注册表项,其中包含调用RegOpenKeyEx的值。然后,您必须调用RegQueryValueEx API,处理许多复杂的细节。例如,如果您使用RegQueryValueEx读取字符串值,则不能保证返回的字符串正确地以NUL终止,这可能会导致代码中出现一系列危险的安全错误。为了防止这种情况的发生,您必须注意检查返回的字符串中是否有NUL终止符;如果没有,则必须添加它。此外,您必须确保调用RegCloseKey正确关闭打开键。

著录项

  • 来源
    《MSDN Magazine》 |2017年第5期|56-586062|共5页
  • 作者

    Giovanni Dicanio;

  • 作者单位
  • 收录信息
  • 原文格式 PDF
  • 正文语种 eng
  • 中图分类
  • 关键词

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号