如何以编程方式检查安装的 Visual Studio 版本?
我可以读取注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0
。 但是,它没有给我任何有关其版本的信息 - 专业版/终极版或其他版本。
如何以编程方式(最好是Python)获取信息?
I could read registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0
.
However, it doesn't give me any information about the edition of it - Professional/Ultimate or whatever.
How can I get the information with programmatically (preferably python)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
如果有人需要 C# 示例,那么:
if somebody needs C# example then:
在cmd中运行路径
C:\Program Files (x86)\Microsoft Visual Studio\Installer>vswhere.exe
Run the path in cmd
C:\Program Files (x86)\Microsoft Visual Studio\Installer>vswhere.exe
对于任何遇到这个问题的人,如果您正在使用 C++,这里是答案:
您可以检查 vs 版本的 cpp 代码,如下例所示,该示例链接基于 2015 或更高版本的 vs 版本的库:
这是在链接时完成的,没有额外的运行时成本。
For anyone stumbling on this question, here is the answer if you are doing C++:
You can check in your cpp code for vs version like the example bellow which links against a library based on vs version being 2015 or higher:
This is done at link time and no extra run-time cost.
它不是很微妙,但安装位置中有一个文件夹,其中包含已安装的版本名称。
例如我有:
和
您可以从上面列出的注册表项中找到安装位置。
或者,这将位于注册表中的多个位置,例如:
有大量带有字符串的值和键,您可以通过在 Regedit>Edit>Find 功能中查找“Microsoft Visual Studio 2010”来找到它们。
您只需要选择您想要的并进行一些字符串匹配即可。
Its not very subtle, but there is a folder in the install location that carries the installed version name.
eg I've got:
and
You could find the install location from the registry keys you listed above.
Alternatively this will be in the registry at a number of places, eg:
There are loads of values and keys with the string in, you can find them by looking for "Microsoft Visual Studio 2010" in the Regedit>Edit>Find function.
You'd just need to pick the one you want and do a little bit of string matching.
此问题的更新答案如下:
解决2019
解决Microsoft.VisualStudio.Product.Professional
An updated answer to this question would be the following :
Resolves to 2019
Resolves to Microsoft.VisualStudio.Product.Professional
此线程中的所有信息现已过时,因为最近发布了 vswhere。下载并使用它。
All the information in this thread is now out of date with the recent release of vswhere. Download that and use it.
将此代码放在 C++ 项目中的某个位置:
请注意,
_MSC_VER
符号是 Microsoft 特定的。 在这里您可以找到列表 Visual Studio 版本的数量,每个版本的值为_MSC_VER
。Put this code somewhere in your C++ project:
Note that
_MSC_VER
symbol is Microsoft specific. Here you can find a list of Visual Studio versions with the value for_MSC_VER
for each version.在 Visual Studio 中,选项卡“帮助”-> “关于 Microsoft Visual Studio”应该会为您提供所需的信息。
In Visual Studio, the Tab 'Help'-> 'About Microsoft Visual Studio' should give you the desired infos.
您可以通过运行以下命令获取VS产品版本。
You can get the VS product version by running the following command.
打开安装好的Visual Studio软件,点击帮助菜单选择关于Microsoft Visual studio-->获取视觉工作室版本
Open the installed visual studio software and click the Help menu select the About Microsoft Visual studio--> Get the visual studio Version