如何从 cpp 文件修改 VS_VERSION_INFO [英] How can I modify VS_VERSION_INFO from the cpp file

查看:81
本文介绍了如何从 cpp 文件修改 VS_VERSION_INFO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我转到资源视图 -> myproject.rc -> 版本 -> VS_VERSION_INFO 时,我有可以更改的字段.可以通过 cpp 文件更改这些字段吗?所以我可以使用类似的东西:

When I go to Resource View -> myproject.rc -> Version -> VS_VERSION_INFO I've got the fields I can change. It is possible to change these fields through cpp file? so I could use something like:

#define FileDescription "This is my program"

那会很酷,因为总是去那里更改这些字段很烦人.

That would be cool because it's annoying to always go there and change these fields.

推荐答案

你不能.版本资源由链接器嵌入到您的 EXE 中,它不是一个变量.Windows 知道如何找到它并在属性"窗口中显示版本.尝试用您的代码修改它在设计上没有用,当用户查看属性时它不会运行.您也不能修改自己的 EXE 文件,它在您的程序运行时被锁定.UAC 会阻止程序修改可执行文件,这是破坏 Roman 方法的冰山.

You can't. The version resource is embedded into your EXE by the linker, it isn't a variable. Windows knows how to find it and display the version in the Properties window. Trying to modify it with your code isn't useful by design, it isn't running when the user looks at the properties. Nor can you modify your own EXE file, it is locked while your program is running. And UAC stops programs from tinkering with executables, the iceberg that sinks Roman's approach.

如果资源编辑器惹恼了您,您不必使用它,.rc 文件只是一个文本文件,您可以使用文本编辑器对其进行编辑,就像您的 .cpp 源代码一样.预处理器首先获取文件,您可以替换字符串,这样只需编辑 .h 文件,.rc 文件 #includes 也可以完成工作.

You don't have to use the resource editor if it annoys you, the .rc file is just a text file that you can edit with a text editor, just like your .cpp source code. And the preprocessor gets a shot at the file first, you can substitute strings so just editing a .h file that the .rc file #includes gets the job done too.

这篇关于如何从 cpp 文件修改 VS_VERSION_INFO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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