Click here to Skip to main content
Click here to Skip to main content

ShowVer.exe command-line VERSIONINFO display program

By , 18 Jun 2002
 

Introduction

Did you ever wish for a way to quickly peek inside a mystery DLL to see who wrote it and what it does? If the DLL has version information built in, you could browse to the DLL file in Windows Explorer and then click through the items in the Version tab of the Properties context menu dialog for the file. That's kind of a nuisance for me, so I wrote this handy program, ShowVer.exe. ShowVer will show you all the version info at once.

The source code for ShowVer will also show you how to traverse the tree of information that a VERSIONINFO resource contains, bypassing the need to use the VerQueryValue Win32 API to retrieve individual strings based on a particular hard-coded key name and language/locale ID that you might be expecting to be present.

ShowVer.exe is a command-line program that displays the complete VERSIONINFO contents of a named file. It works on EXE's and DLL's. It is useful for 3 reasons:

  1. It shows all the version info from a file, in all its languages. It does this by interpreting the raw data structures that compose a VERSIONINFO resource. The Win32 APIs (VerQueryValue) will only show you a value from the VERSIONINFO resource if you ask for it by name.
  2. It allows you to name the file whose information you want to see. Often the file you want to examine resides in the System32 directory, which is crowded and unpleasant to browse through using Windows Explorer.
  3. It is a standalone command-line utility that operates on external files, unlike DLLVersion which is a tool you incorporate into a running process.

The source code to ShowVer demonstrates how to load (using GetFileVersionInfo and GetFileVersionInfoSize), parse and traverse the tree of pseudo-structures that make up a VERSIONINFO resource (VS_VERSIONINFO, String, StringTable, StringFileInfo, Var, VarFileInfo).

It will also display a hex dump of the raw VERSIONINFO resource block if you rebuild it with '#define HDUMP 1'. One interesting observation from the hex dump feature is that GetFileVersionInfo never seems to fill up the whole memory buffer that GetFileVersionInfoSize requests.

Here is sample output from ShowVer.exe:

N:\work\ShowVer\Debug>ShowVer w:\winnt\system32\mshtml.dll
VERSIONINFO for file "w:\winnt\system32\mshtml.dll":  (type:0)
  Signature:       feef04bd
  StrucVersion:    1.0
  FileVersion:     6.0.2600.0
  ProductVersion:  6.0.2600.0
  FileFlagsMask:   0x3f
  FileFlags:       0
  FileOS:          VOS_NT_WINDOWS32
  FileType:        VFT_DLL
  FileDate:        0.0
 LangID: 040904B0
  CompanyName       : Microsoft Corporation
  FileDescription   : Microsoft (R) HTML Viewer
  FileVersion       : 6.00.2600.0000
  InternalName      : MSHTML
  LegalCopyright    : ¬ Microsoft Corporation. All rights reserved.
  OriginalFilename  : MSHTML.DLL
  ProductName       : Microsoft« Windows« Operating System
  ProductVersion    : 6.00.2600.0000
  OleSelfRegister   :
 Translation: 040904b0

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

tpeck
Web Developer
Anonymous Proxy Anonymous Proxy
Member
Ted Peck is a consultant with over 20 years' experience in software development and technical management. His company, Roundwave Development, specializes in designing GUI, network and database tools and systems.
 
Ted believes in thoughtful systems design with the aim of maximizing utility while minimizing complexity. If you're careful you can build software that's both powerful and easy to use.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionPrint Unicode [modified]memberacourier12 Apr '12 - 2:47 
Does anybody know what modifications are needed to support printing Unicode -> System Locale in version info?
Apparently,
printf("%S", psVal)
doesn't produce desired output for 0x041904E3 locale. It omits any non-ascii characters
 LangID: 041904E3
  CompanyName       :
  FileDescription   :
  FileVersion       : 1.0.0.1
  InternalName      :
  LegalCopyright    : Copyright  (c)
  LegalTrademarks   :
  OriginalFilename  :
  ProductName       :
  ProductVersion    : 1.01
  Comments          :
P.S. I got it!
#include <locale.h>
...
int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
{
	setlocale(LC_CTYPE, ".OCP");


modified 13 Apr '12 - 8:05.

GeneralResourceLib: same thing in C# with r/wmemberdB.8 Oct '08 - 12:27 
If you're looking for a .NET library to do this, take a look at http://www.codeproject.com/KB/library/ResourceLib.aspx[^], it can both read and write version, string, icon and other resources.
 

GeneralSee also sigcheck from sysinternalsmemberbrofield29 Jan '07 - 7:23 
Hi,
 
There is also the sigcheck utility from sysinternals that gives a summarized view of the file version. Not a complete dump like yours though.
http://www.microsoft.com/technet/sysinternals/FileAndDisk/Sigcheck.mspx
 
Regards,
Brodie

GeneralRelayer's comment - A fix for thissussAnonymous29 Sep '05 - 15:52 
The fix to this "problem" is not in the code, but in a setting on your PC. See this article. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dynamic-link_library_search_order.asp
If you have no such entry, the DEFAULT behavior appears to be INCORRECT in the article. Create the key if it doesnt exist and set its value to 0.
GeneralRe: Relayer's comment - A fix for thismemberrelayer_delirium29 Sep '05 - 16:00 
Note that the search order ALWAYS will look for the target in the same directory that ShowVer was launched in ... so make sure its in the path, but isolated from other EXEs and DLLs. So, I solved my own problem ... and apologies to Mr. Peck for inferring that he programmed this badly!

GeneralUnderstanding the codememberlstoumbos7 Sep '05 - 5:09 
Confused | :confused: I was wondering if someone could into detail for me on whats going on in the code with these 2 functions

#define roundoffs(a,b,r) (((byte*)(b) - (byte*)(a) + ((r)-1)) & ~((r)-1))
#define roundpos(b, a, r) (((byte*)(a))+roundoffs(a,b,r))

and why they are needed.
Any help is greatly appreciated.
 
Luke
GeneralLoading ALL strings from my stringtablememberAlex Evans4 May '05 - 15:05 
Hi there
 
How can I (using VC6 / MFC) load ALL strings from a stringtable, one-by-one, getting the IDS value as well as the actual text, for all strings in my program's stringtable?
 
Thanks
 
Alex
Generaldebug assertion failedmemberKaren Amstutz13 Jul '04 - 11:03 

I have a delphi exe that I am running the showver against.
I am getting
 
Debug Assertion Failed
Expression 1== psfI >wtype
 
I have tried taking all my debug option out but I still get the error........Any suggetions

GeneralRe: debug assertion failedmemberacourier12 Apr '12 - 1:56 
That's because Delphi generates wType=0 for StringFileInfo, VarFileInfo and StringTable in VS_VERSIONINFO structure and ASSERT(1 == pSFI->wType) fires.
You can see structures definition on http://msdn.microsoft.com/en-us/library/ms647001.aspx
Simply comment out two lines in ShowVer.cpp
473: ASSERT(1 == pSFI->wType);
490: ASSERT(1 == pSFI->wType);
for VC++ 2008/2010 (might be also needed for earlier VC++ versions) modify line
501: printf("%04x%04x ", (int)*wpos, (int)(*(wpos+1)));

Generalincorrect search ordermemberrelayer_delirium9 Mar '04 - 15:37 
Showver seems to find a file in the path before it finds one in the immediate directory. If for example file X.EXE is in the current directory and in c:\windows\system32, issuing the command "showver x.exe " gives me the version info of the copy in c:\windows\system32. To get the current folder I use "showver .\x.exe" ... but I shouldnt have to. Can this be fixed?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 19 Jun 2002
Article Copyright 2002 by tpeck
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid