Using Delphi to modify the version information of another delphi program

前端 未结 2 1014
无人共我
无人共我 2021-02-11 06:24

I was wanting to create a small tool in Delphi which can update the Delphi version information in another exe file. I know several existing utilities are out there for this but

相关标签:
2条回答
  • 2021-02-11 06:46

    There's also Colin Wilson's XN Resource Editor with source code which might help.

    0 讨论(0)
  • 2021-02-11 07:08

    I can't give a complete answer, but I can get you started. There is an article at DelphiDabbler.com that fills in how to get to the version information out of a file. GetFileVersionInfo is the Windows API to do that. To set it, I believe UpdateResource is the Windows API function you'll need to use. There is another article at CodeProject that covers this, using C, but it should give you a solid idea of what needs to be done.

    Good luck!

    Edit: I found some code on the Delphi newsgroups that might give you some more help:

    // Credit to Michael Winter for this code!
    Sz := GetLen;
    GetMem(Data, Sz);
    try
      GetData(Data, Sz);
      HFile := BeginUpdateResource(PChar(FileName), false);
      if HFile = 0 then
        RaiseLastWin32Error;
      DoDiscard := true;
      try
        if not UpdateResource(HFile, RT_VERSION, PChar(1), 0, Data, Sz) then
          RaiseLastWin32Error;
        DoDiscard := false;
      finally
        if not EndUpdateResource(HFile, DoDiscard) then
          RaiseLastWin32Error;
      end;
    finally
      FreeMem(Data);
    end;
    

    It's just a snippet, and will require some work on your part, but that's the lion's share of the work!

    0 讨论(0)
提交回复
热议问题