You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无需重新编译即可更新DLL文件版本号的实现方法咨询

无需重新编译即可更新DLL文件版本号的实现方法咨询

我手里有一些版本号不正确的.dll文件,想不用重新编译就把它们的版本号改成正确值。我找到了UpdateResource这个Windows API函数,打算通过Platform Invoke(也就是大家常说的P/Invoke)来实现这个功能。

以下是我目前写的代码:

public class UpdateBinaryResource {

class VersionResourceUpdater
{
    [DllImport("kernel32.dll", SetLastError = true)]
    private static extern IntPtr BeginUpdateResource(string pFileName, bool bDeleteExistingResources);

    [DllImport("kernel32.dll", SetLastError = true)]
    private static extern bool UpdateResource(IntPtr hUpdate, IntPtr lpType, IntPtr lpName, ushort wLanguage, byte[] lpData, uint cbData);

    [DllImport("kernel32.dll", SetLastError = tru...

备注:内容来源于stack exchange,提问作者Alfyn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 08:54:49