[SOLVED] Show windows details about the executable file or library

Windows specific questions.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

[SOLVED] Show windows details about the executable file or library

Post by exagonx »

Hello friends.

There is a way to bring up information in detail such as:
File version
Product name
Version
Copyright
Language
I searched but I don't know what exactly to look for.
Last edited by exagonx on Mar 17, 2022 1:57, edited 1 time in total.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Show windows details about the executable file or library

Post by dodicat »

You can try this (windows)

Code: Select all


Function Pipeout(Byval s As String="")As String
    Var f=Freefile
    Dim As String tmp
    Open Pipe s For Input As #f 
    s=""
    Do Until Eof(f)
        Line Input #f,tmp
        s+=tmp+Chr(10)
    Loop
    Close #f
    Return s
End Function 

Function SAR(byval s As String,s1 As String,s2 As String) As String
   var position=Instr(s,s1)
    While position>0
        s=Mid(s,1,position-1) & s2 & Mid(s,position+Len(s1))
        position=Instr(position+Len(s2),s,s1)
    Wend
    return s
End Function

function details(path as string) as string
if instr(path,"\\")=0 then path=SAR(path,"\","\\")
return pipeout("wmic datafile where name="+chr(34)+path+chr(34)+" get /VALUE ")
end function


print details("C:\windows\system32\notepad.exe")
sleep 
adeyblue
Posts: 299
Joined: Nov 07, 2019 20:08

Re: Show windows details about the executable file or library

Post by adeyblue »

The 'yourself' way is

Code: Select all

versionDataSize = GetFileVersionInfoSize(filePath, @temp)
pBuffer = allocate versionDataSize bytes
GetFileVersionInfo(filePath, temp, versionDataSize, pBuffer)
'' Version numbers and bulid-times are in the root block
dim as VS_FIXEDFILEINFO fixedInfo
path = "\"
VerQueryValue(pBuffer, path, @fixedInfo, @tempLen)
'' Then the page for VerQueryValue shows you how to get the different languages of the description, comments, etc
'' https://docs.microsoft.com/en-us/windows/win32/api/winver/nf-winver-verqueryvaluea
'' To build the string in FB its 
'' langPath =  "\StringFileInfo\" + Hex(lpTranslate[i].wLanguage, 4) + Hex(lpTranslate[i].wCodePage, 4)
'' then
'' path = langPath + "\FileComments"
'' VerQueryValue(pBuffer, path, @wstringPtr, @tempLen)
'' path = langpath + "\ProductName"
'' VerQueryValue(pBuffer, path, @wstringPtr, @tempLen)
'' etc until
free the allocated pBuffer '' 
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Show windows details about the executable file or library

Post by exagonx »

dodicat wrote: Mar 15, 2022 0:41 You can try this
Thanks for your quick and helpful reply.

I will need these examples for another project but it was not what I asked for.

I apologize for being unclear.

When right-clicking on an executable file, properties, details, this gives a screen where it shows information about the executable file.

Where is this information stored?
Where are they inserted in the source?
Last edited by exagonx on Mar 17, 2022 1:57, edited 1 time in total.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Show windows details about the executable file or library

Post by dodicat »

Here is what you asked for:
...
Hello friends.

There is a way to bring up information in detail such as:
File version
Product name
Version
Copyright
Language
I searched but I don't know what exactly to look for.
...

You didn't ask anything about:

Where is this information stored?
Where are they inserted in the source?

Please check out windows manifest files (.xml) and loading them via resource files (.rc)
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Show windows details about the executable file or library

Post by exagonx »

dodicat wrote: Mar 15, 2022 20:38 Here is what you asked for:
thanx you dodicat.
Actually the only thing I can refer to is that by clicking with the right mouse button the menu with the item "Properties" appears and from the window I select the "Details" tab, I have no idea what to ask because on visual studio this information is inserted in the general information of the solution, but with FreeBASIC I don't know if it is possible to insert it accordingly I don't even know what to ask, I just hope I can explain myself.

In any case, I thank you and I thank you all for your availability.
Last edited by exagonx on Mar 17, 2022 1:57, edited 1 time in total.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Show windows details about the executable file or library

Post by dodicat »

Please try this
file.rc

Code: Select all


1 VERSIONINFO
FILEVERSION     1,0,0,0
PRODUCTVERSION  1,0,0,0
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "080904E4"
    BEGIN
      VALUE "CompanyName", "Some company"
      VALUE "FileDescription", "Some description"
      VALUE "FileVersion", "1.0"
      VALUE "InternalName", "Some file name"
      VALUE "LegalCopyright", "Some copyright"
      VALUE "OriginalFilename", "shell.exe"
      VALUE "ProductName", "Some product name"
      VALUE "ProductVersion", "1.0"
    END
  END

  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x809, 1252
  END
END 
then shell.bas

Code: Select all

#cmdline "file.rc"
print "Hello"
sleep

 
Keep both files in the same folder, then compile shell.bas to shell.exe
You will see values in right click-properties-details hopefully.
fb1.09 at least required, otherwise file.rc must be on the command line.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Show windows details about the executable file or library

Post by exagonx »

@dodicat

Hi thank you for your tip, but maybe its something wrong.

Code: Select all

D:\resurce>fbc shell.bas
Error!
Line 1 of Resource Script (file.RC):-
Could not find file:-
1

OBJ file not made
D:\resurce>
This is what appair
I copy and paste the code like you post it but I give that error.
Last edited by exagonx on Mar 17, 2022 1:56, edited 1 time in total.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Show windows details about the executable file or library

Post by dodicat »

I tried this on 64 and 32 bits in three different ides, no problems.
Win 10 fb 1.09 (official build)
Are file.rc and shell.bas in the same folder?
They have to be otherwise file.rc will not be found.
That's all I can think of just now.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Show windows details about the executable file or library

Post by exagonx »

@dodicat
Dont worry Tank you for your help.

Anyway
This is my status
Windows 10 Professional 64bit

Code: Select all

D:\resurce>fbc shell.bas
Error!
Line 1 of Resource Script (file.RC):-
Could not find file:-
PDC_VER_MAJOR

OBJ file not made

D:\resurce>dir
 Il volume nell'unità D è DataProfile
 Numero di serie del volume: E215-71B9

 Directory di D:\resurce

16/03/2022  15:05    <DIR>          .
16/03/2022  15:05    <DIR>          ..
16/03/2022  00:43               879 file.rc
16/03/2022  00:26                42 shell.bas
               2 File            891 byte
               2 Directory  1.311.370.477.568 byte disponibili

D:\resurce>fbc --version
FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win64 (64bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone

D:\resurce>
Last edited by exagonx on Mar 17, 2022 1:55, edited 1 time in total.
PaulSquires
Posts: 999
Joined: Jul 14, 2005 23:41

Re: Show windows details about the executable file or library

Post by PaulSquires »

What folder do you have the FBC.exe compiler installed in? Is the folder in a path that contains spaces? I have had occasional problems compiling rc resource files if the compiler is in a path containing spaces. This may be a long shot, but at least it is worth a try checking.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Show windows details about the executable file or library

Post by exagonx »

@PaulSquires

Nope no space in the path

Code: Select all

D:\resurce>\freebasic\fbc shell.bas
Error!
Line 1 of Resource Script (file.RC):-
Could not find file:-
PDC_VER_MAJOR

OBJ file not made

D:\resurce>
Last edited by exagonx on Mar 17, 2022 1:55, edited 1 time in total.
adeyblue
Posts: 299
Joined: Nov 07, 2019 20:08

Re: Show windows details about the executable file or library

Post by adeyblue »

There's definitely something different in your file.rc. The text you posted is 593 bytes, your dir says its 879 bytes. Though it also says 879 + 42 is 891. If you didn't edit it, then it looks like you have bigger problems than getting this to compile
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Show windows details about the executable file or library

Post by exagonx »

@adeyblue

I changed some value in

Code: Select all

     VALUE "CompanyName", "Some company"
      VALUE "FileDescription", "Some description"
      VALUE "FileVersion", "1.0"
      VALUE "InternalName", "Some file name"
      VALUE "LegalCopyright", "Some copyright"
      VALUE "OriginalFilename", "shell.exe"
      VALUE "ProductName", "Some product name"
      VALUE "ProductVersion", "1.0"
I tried with the original file and it gives the same error
Last edited by exagonx on Mar 17, 2022 1:55, edited 1 time in total.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Show windows details about the executable file or library

Post by exagonx »

adeyblue wrote: Mar 16, 2022 20:07 There's definitely

Code: Select all

D:\resurce>dir
 Il volume nell'unità D è DataProfile
 Numero di serie del volume: E215-71B9

 Directory di D:\resurce

16/03/2022  21:49    <DIR>          .
16/03/2022  21:49    <DIR>          ..
16/03/2022  21:44               569 file.rc
16/03/2022  00:26                42 shell.bas
               2 File            611 byte
               2 Directory  1.306.066.735.104 byte disponibili

D:\resurce>type file.rc
1 VERSIONINFO
FILEVERSION     1,0,0,0
PRODUCTVERSION  1,0,0,0
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "080904E4"
    BEGIN
      VALUE "CompanyName", "Some company"
      VALUE "FileDescription", "Some description"
      VALUE "FileVersion", "1.0"
      VALUE "InternalName", "Some file name"
      VALUE "LegalCopyright", "Some copyright"
      VALUE "OriginalFilename", "shell.exe"
      VALUE "ProductName", "Some product name"
      VALUE "ProductVersion", "1.0"
    END
  END

  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x809, 1252
  END
END

D:\resurce>type shell.bas
#cmdline "file.rc"
print "Hello"
sleep

D:\resurce>
Last edited by exagonx on Mar 17, 2022 1:54, edited 1 time in total.
Post Reply