在 VB.NET 中编辑可执行文件的元数据

发布于 2025-01-06 10:58:55 字数 64 浏览 3 评论 0原文

我读了很多关于更改音乐或图像元数据的文章,但是普通的可执行文件呢?如何编辑它们的评论/标题?我正在使用.NET 2

I read a lot about changing the metadata of music or images, but what about normal executable? How do I edit the comment / title of them? I am using .NET 2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠檬 2025-01-13 10:58:55

您可以通过简单地包含程序集属性来指定有关 .NET 程序集的各种元数据,如下所示:

<Assembly: AssemblyTitle("ConsoleApplication9")> 
<Assembly: AssemblyDescription("Blah")> 
<Assembly: AssemblyCompany("My Company")> 
<Assembly: AssemblyProduct("ConsoleApplication9")> 
<Assembly: AssemblyCopyright("Copyright © My Company 2012")> 
<Assembly: AssemblyTrademark("")> 

通常,您将这些属性放在名为 AssemblyInfo.vb 的文件中,并将其编译到程序集中(Visual Studio 将生成此文件)如果您转到项目设置 - 应用程序|程序集信息,请从您设置的设置中查看项目文件夹,默认情况下有一个与您的项目同名的子文件夹。其中有前面提到的 .vb 文件)。

但是,如果您想更新预编译的 .NET 程序集,我认为您需要反编译它,更改您想要更改的清单中的属性,然后重新编译它。您可以使用 ildasm 工具来执行此操作。如果程序集是强命名的,您将无法使用与编译时相同的强名称来重新编译它。

You can specify various bits of metadata about a .NET assembly by simply including assembly attributes like so:

<Assembly: AssemblyTitle("ConsoleApplication9")> 
<Assembly: AssemblyDescription("Blah")> 
<Assembly: AssemblyCompany("My Company")> 
<Assembly: AssemblyProduct("ConsoleApplication9")> 
<Assembly: AssemblyCopyright("Copyright © My Company 2012")> 
<Assembly: AssemblyTrademark("")> 

Normally you place these in a file called AssemblyInfo.vb and compile it into your assembly (Visual Studio will generate this for you from the settings you set if you go to project settings - Application | Assembly Information. Have a look in the project folder, there is by default a sub-folder with the same name as your project and in there is the aforementioned .vb file).

If you want, however, to update a precompiled .NET assembly I think you would need to decompile it, change the attributes in the manifest you want to change and re-compile it. You can do this using the ildasm tool. If an assembly is strong named you will not be able to recompile it using the same strong name than it was compiled with of course.

可遇━不可求 2025-01-13 10:58:55

注释或标题等属性并不是为所有文件均等提供的,因为它们不是由文件系统存储而是来自文件本身。因此它们必须是文件格式的一部分,并且并非所有文件格式都提供此类属性。事实上,许多文件格式根本不提供任何属性(例如.txt)。即使文件格式支持某些属性,Windows 也需要安装自定义属性处理程序来提取、解释并可能修改它们。

可执行文件通过版本信息资源。然而它们不能也不应该被改变,因为这会弄乱文件校验和,破坏数字签名等。

Properties like comment or title are not provided for all files equally, because they are not stored by the filesystem but come from the file itself. Therefore they must be part of the file format and not all file formats provide such properties. Indeed, many file formats don't provide any properties at all (e.g. .txt). Even when the file format supports some properties, Windows needs a custom property handler installed to extract, interpret and possibly modify them.

Executables provide some read-only properties through the version information resource. However they cannot and should not be changed, because this will mess up file checksums, break digital signatures etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文