用cmake读取注册表值 [英] Reading registry values with cmake

查看:129
本文介绍了用cmake读取注册表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 7计算机上,我无法读取任何包含分号的注册表值。

On a Windows 7 machine I cannot read any registry values that contain a semicolon.

例如,如果您使用7-zip,请运行以下命令

For example if you have 7-zip, running the following

SET(MYPATH  [HKEY_LOCAL_MACHINE\\SOFTWARE\\7-Zip;Path])
MESSAGE("MYPATH = ${MYPATH}")

结果

MYPATH = [HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip;Path]

而不是按照以下 thread 。我认为cmake支持包含;的注册表路径在Windows 7上损坏。有人可以确认吗?有解决方法吗?

instead of the actual path as per the following thread. I think cmake support for registry paths that contain ";" are broken on Windows 7. Can somebody confirm this? Is there any work-around?

推荐答案

根据Wiki ,您不能使用 SET 查看注册表项的值。仅当您对其执行某些缓存操作时,才会读取注册表值。例如,以下应输出所需的路径:

According to the wiki, you can't use SET to view the value of a registry key. The registry value is only read when you do some cache operation on it. For example, the following should output the path you want:

GET_FILENAME_COMPONENT(MYPATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\7-Zip;Path]"
                       ABSOLUTE CACHE)
MESSAGE("MYPATH = ${MYPATH}")

这篇关于用cmake读取注册表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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