How to read properties of a executable file? - winapi

I want to read the file properties like File Description , Product name , Copyright of a exe file. Is there any Windows API for it?

Yes. It may not be evident to find it because the Version Information chapter is hidden below Menus and other Resources. The rationale for that is that it is stored is the executable files (including DLL) as a VERSIONINFO resource that was originally intented to help install tools to know whether the version to install was more recent than an existing version.
You will find examples for using it in the linked page to the MSDN and also in SO in different places, for example here

Those values are stored in the file's version info resource. You can use GetFileVersionInfo() and VerQueryValue() to read them.

Related

Visual c++ programatically get file version number within the file itself

I know I can call GetFileVersionInfo() windows API to retrieve file version information.
Is there an easier way to determine the version information, from within the program itself?
For example, suppose I am writing codes for Foo.dll, and inside Foo.dll, I want to support a version function, say GetFooVersion(), which reports the version number of Foo.dll.
If I have to use GetFileVersionInfo(), then I need to search which Foo.dll in the path that is been linked (dynamically), and apply GetFileVersionInfo(). It's tedious and error-prone.
The target visual studio version is VS2012.
There is no GetFileVersionInfoByHandle nor GetFileVersionInfoFromModule unfortunately.
You can use FindResource etc. on your own module but you then have to parse the version info yourself because GetFileVersionInfo does not always retrieve the raw resource data (it can translate to/from Unicode etc.).
Another option is to put version #defines in a .h file that your function and your resource.rc can use so you only have to update a single file when the version changes.

GetVersionEx function for Windows 8.1 and upper (fasm)

I am writting application in fasm and have problem with determinating Windows version 8.1 and upper. Functions GetVersionEx and Version Helper give me Windows 8. As MSDN says, I must target my application via changing manifest file in Visual Studio, but I'm not using VS, so what should I do?
Any programming environment that allows you to link resources into the compiled executable can be used to create a manifest resource. All you have to do is write a suitable .manifest file for your app that contains the desired XML values, and then link that file's content directly into your application's resources, making sure the resource type is 24 and the resource ID is 1, 2, or 3 (see this page for details about when to use which ID). You are not required to use VisualStudio for this.
If, for some reason, you cannot link the manifest directly into your app's resources, you can alternatively save the XML into a file named <myappname>.exe.manifest (where <myappname> is the actual name of your EXE file) and put it in the same folder as your app. This is not the preferred approach to manifestation, but it does work.
That being said, there are alternative APIs you can use instead of GetVersion/Ex() or VerifyVersionInfo()-based helpers to get the correct OS version without dealing with manifestation at all. Namely, RtlGetVersion(), NetServerGetInfo(), and NetWkstaGetInfo() can be used instead (and all of them have been tested as working in Windows 8.1 and 10).
The manifest file is XML file embedded as Win32 resource. It can also be external file with the name your.exe.manifest. Search for examples in internet for sample contents.

How can we get Source File revision number from pdb file?

We have source server enabled, and source indexing is implemented according Using SrcSrv (MSDN). Debugger intelligently Copies the file from the server to the local cache. This works fine on developer machine.
Using IdebugSymbols Interface, we are able to retrieve information from pdb files. We have IdebugSymbols API functions for retrieving file name, source line number, module name etc.
Reference: IDebugSymbols interface (MSDN)
My query is whether we can retrieve Source File revision number from .pdb file using some Microsoft API?
Please let me know if the problem is not understood or you require some more inputs from my side. Thanks :)
I found one more general approach using Microsoft tools called "pdbstr.exe"and "Srctool.exe". These tools can be found at this location %PROGRAMFILES%\Debugging Tools for Windows (x86)\srcsrv
(from: Source Server (MSDN))
These tools simply interacts with pdb symbols file and fetches the information. So I was interested in fetching following info and yes that answers my question.
- What are all files which are Indexed with their revision number?

How can I programmatically read what version of software I am using?

How can I programmatically read what version of software I am using?
If I use Visual Studio to create a project, and that project includes a resource (.rc) file and the version is specified in that file, how can I use code to "read" the version information?
That is, if I want the software to report what version it is when it is run, and the only place this information is stored is in the .rc file, what can I do?
You want to use GetFileVersion() and related functions.
You can use GetFileVersionInfo with the name of the current executable/dll to read the version information, which was embedded into the exe/dll when it was built from the resource file.
Assuming that you are using VERSIONINFO in your resource files, use these functions.

How do I change an EXE or DLL version number from the command line?

I need to build an old VB6 application with a version number where the 4th digit is greater than 9999, for example, version 1.2.0.10003. VB6 won't let you do this; the build fails.
The current workaround is to build version 1.2.0.9999 and then manually edit the file in Visual Studio to insert the correct version. There must be a better way. Is there a command-line tool that allows you to modify the version number fields of an EXE or DLL? Preferably a way that allows you to edit specific version number fields individually.
ChangeVersion (and others) taken from:
How do I set the version information for an existing .exe, .dll?
There are a number of tools for editing the version info of a windows executable but I don't think you will need them.
Look here are using resource files in vb
http://visualbasic.about.com/od/usevb6/a/ResVB6.htm
And here for info on the version resource
http://msdn.microsoft.com/en-us/library/aa381058.aspx
And here for info on the microsoft resource compiler
http://msdn.microsoft.com/en-us/library/aa381042(VS.85).aspx
With these two you should be able to disable VB's builtin versioning and use whatever version info you want.
Nevermind, VB6 inserts its own version resource as a post build operation with no way to turn it off. Overwriting the version info in the executable is the only solution.
See http://www.darinhiggins.com/?s=%22resource+files%22
Resource Tuner Console
This console resource editor allows creating a reliable and repeatable
process for updating Product Version Information resources during the final
stage of the build process from the command prompt.
See specifically the batch manipulation of file version information page for greater details:
http://www.heaventools.com/rtconsole-update-version-info.htm
StampVer
I think editbin might be a better solution (installed with Visual Studio)

Resources