0

I use a RC (resource) file to get version information linked into the EXE file, and recently I switched from Borland Resource Compiler to Windows SDK Resource Compiler, in order to be able to use multiple sizes icons in my application.

The icon worked, but now when I compile my application the resource information seems to not be attached to the EXE file. I'm suspecting that the same RC file that works for BRCC32.EXE does not work for the Windows SDK Resource Compiler.

Here is my verinfo.rc content:

VS_VERSION_INFO VERSIONINFO
FILEVERSION             1,0,0,0
PRODUCTVERSION          1,0,0,0
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
        VALUE "Comments",         "Company Soft\0"
        VALUE "CompanyName",      "Company2\0"
        VALUE "FileDescription",  "Company Soft\0"
        VALUE "FileVersion",      "x.x.x.x\0"
        VALUE "InternalName",     "Company Soft\0"
        VALUE "LegalCopyright",   "Company2\0"
        VALUE "OriginalFilename", "abrev.exe\0"
        VALUE "ProductName",      "Company Soft\0"
        VALUE "ProductVersion",   "x.x.x.x\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0409,1200
    END
END

And here is how my EXE file shows in Explorer's file properties: Explorer file properties showing no EXE version information

Finally, I'm not forgetting to use the verinfo.rc file in my Delphi project file:

program myprogram;
{$R 'verinfo.res' 'verinfo.rc'}

Update #1

If I change the resource compiler back from Windows SDK Compiler to Borland Resource Compiler the version information is included into the EXE file (but I cannot use multiple sizes icons anymore): Delphi project settings: Resource Compiler Explorer file properties showing EXE version information as wanted

Update #2

Using the resource editor Resource Hacker I can see there is indeed version information resource in the EXE file. But I can't see this in Windows Explorer, and also can't retrieve this with a WinAPI function like GetFileVersionInfo: Resource Hacker displays VS_VERSION_INFO resource

Update #3

Here is what I found what happens when using the same RC file but with different resource compilers:

  1. When using Borland Resource Compiler everything works fine, with the version info shown in Windows Explorer; Resource Hacker shows this:

    Resource Hacker showing resource "1"

  2. When using Windows SDK Resource Compiler version information still shows in Resource Hacker but not in Windows Explorer:

    Resource Hacker showing resource "VS_VERSION_INFO"

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
delphirules
  • 6,443
  • 17
  • 59
  • 108
  • Are you building through the IDE? If so, maybe your verinfo.rc data gets overridden by the Project Options' version data? – Andreas Rejbrand Dec 06 '21 at 11:24
  • @AndreasRejbrand Both from IDE or command line, i get the same problem... The box 'Include version information in project' on Project options > Application > Version info is NOT checked – delphirules Dec 06 '21 at 11:26
  • What if you change `040904b0` to `040904E4`? And `VALUE "Translation", 0x0409 0x04E4` at the bottom? – Andreas Rejbrand Dec 06 '21 at 11:31
  • Tried this, but still empty details on EXE property. It's strange because this same .rc file always worked for me, until i switched the resource compiler – delphirules Dec 06 '21 at 11:33
  • Ahem: "_always_" = [for less than 2 months](https://stackoverflow.com/q/69485477/4299358). Have you looked into the EXE with a hex editor to search for expected strings? Just because _Explorer_ isn't displaying version info doesn't mean it's not in the file. – AmigoJack Dec 06 '21 at 11:49
  • Even better: A resource editor. – Andreas Rejbrand Dec 06 '21 at 11:53
  • @AmigoJack The issue on the question you mentioned was not the same on this question ; it was a problem related to invalid chars being shown, but the version information was always there. Now the problem is simply no information is attached to the EXE – delphirules Dec 06 '21 at 11:54
  • @AndreasRejbrand I tried to use this function on Delphi to get version info, and no information is retrieved : https://stackoverflow.com/questions/17279394/getfileversioninfosize-and-getfileversioninfo-return-nothing/17286050#17286050 – delphirules Dec 06 '21 at 11:56
  • UPDATE : I can confirm that if change the resource compiler back to Borland Resource Compiler, version info goes back to EXE file. I'll update the question – delphirules Dec 06 '21 at 11:59
  • Maybe i need to use Windows SDK recource compiler to the icon file and Borland to the version info ? – delphirules Dec 06 '21 at 12:06
  • Microsoft SDK resource compiler handles the RC files a bit differently. You can read about some of the differences in [Delphi documentation](https://docwiki.embarcadero.com/RADStudio/Alexandria/en/RC.EXE,_the_Microsoft_SDK_Resource_Compiler) – SilverWarior Dec 06 '21 at 12:25
  • @Brian Thanks for the suggestion, i tried this instead of the one on my question, but still, no version information attached to EXE unless i use the Borland Resource Compiler instead of Windows SDK one – delphirules Dec 06 '21 at 12:31
  • UPDATE 2 on question – delphirules Dec 06 '21 at 12:35
  • @TomBrunberg You mean add \n instead of \0 ? – delphirules Dec 06 '21 at 12:43
  • UPDATE 3 on question – delphirules Dec 06 '21 at 12:58
  • That's the proof: you wrongly assumed that the resource is not inside the EXE just because Explorer didn't display it. Looking into a hex editor should be the 1st step, looking into a resource editor the 2nd. First verify that the linker does its job, then verify the resource format is correct. – AmigoJack Dec 07 '21 at 00:19
  • @AmigoJack You are right, the resource was in the EXE. That's why i did the update 3 – delphirules Dec 07 '21 at 18:43

1 Answers1

3

Version resource in DLL not visible with right-click fixed the issue: Basically I changed the first line of my .rc file from

VS_VERSION_INFO VERSIONINFO

to

1 VERSIONINFO

Now everything works!

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
delphirules
  • 6,443
  • 17
  • 59
  • 108
  • According to [the documentation](https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource#parameters) it should always be `1`. – AmigoJack Dec 06 '21 at 15:59
  • 1
    Well done for sorting this out for yourself! – MartynA Dec 06 '21 at 17:06
  • @AmigoJack It's odd because if i use the Borland Resource Compiler, it will work the other way. Anyway, thanks for the info – delphirules Dec 06 '21 at 17:35
  • 2
    This implies that the `VS_VERSION_INFO` identifier is not being defined by the resource compiler, so the `.rc` script needs to do it explicitly, eg: `#ifndef VS_VERSION_INFO #define VS_VERSION_INFO 1 #endif`. When declaring a resource, if its ID is not a numeric value, it will be used as-is as a string name instead. You can clearly see this happening in your screenshots. – Remy Lebeau Dec 06 '21 at 18:00