Solved

Device Driver Version (win32 device management/device services)

Posted on 2008-06-16
3
276 Views
Last Modified: 2013-12-04
How can I find the version of a device driver?

SetupDiGetDeviceRegistryProperty does not seem to be what I want because none of the SPDRP_... constants include anything about version information.

How does the device manager for windows do it, for example?
0
Comment
Question by:henrybaxter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 21799061
You can read the version number directly from the binary, see http://support.microsoft.com/kb/167597 ("SAMPLE: GetVers.exe Specifies Component FileVersion and #Version"). The scoop is to
#include <windows.h>
#include <iostream>
#pragma comment ( lib, "version.lib")
 
using namespace std;
 
   void reportError()
   {
       LPVOID lpMsgBuf;
 
       FormatMessage(
           FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
           NULL,
           GetLastError(),
           MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
           (LPTSTR) &lpMsgBuf,
           0,
           NULL );
 
       cout << (char*)lpMsgBuf << "\n";
 
       // Free the buffer.
       LocalFree( lpMsgBuf );
   }
 
   void main( int argc, char *argv[ ], char *envp[ ] )
   {
       cout << "\n";
 
       if(2 != argc)
       {
           cout << "Syntax: GetVer <File Name>\n";
           return;
       }
 
       DWORD dwArg;
       DWORD dwInfoSize = GetFileVersionInfoSize(argv[1], &dwArg);
 
       if(0 == dwInfoSize)
       {
           cout << "No version info available\n";
           reportError();
           return;
       }
 
       BYTE* lpBuff = new BYTE[dwInfoSize];
 
       if(!lpBuff)
       {
           cout << "Out of Memory\n";
           return;
       }
 
       if(0 == GetFileVersionInfo(argv[1], 0, dwInfoSize, lpBuff))
       {
           cout << "Error retrieving version info\n";
           reportError();
           return;
       }
 
       VS_FIXEDFILEINFO *vInfo;
 
       UINT uInfoSize;
 
       if(0 == VerQueryValue(lpBuff, TEXT("\\"),
               (LPVOID*)&vInfo,
               &uInfoSize))
       {
           cout << "Version information not available\n";
           delete lpBuff;
           return;
       }
 
       if(0 == uInfoSize)
       {
           cout << "Version information not available\n";
           delete lpBuff;
           return;
       }
 
       cout << argv[1]
           << " Version: "
           << HIWORD(vInfo->dwFileVersionMS) << ","
           << LOWORD(vInfo->dwFileVersionMS) << ","
           << HIWORD(vInfo->dwFileVersionLS) << ","
           << LOWORD(vInfo->dwFileVersionLS) << "\n";
 
       delete lpBuff;
   }

Open in new window

0
 

Author Closing Comment

by:henrybaxter
ID: 31467824
Sorry for the delay - I had to make sure I understood it!

Thanks for the help, it's very much appreciated.
0
 
LVL 86

Expert Comment

by:jkr
ID: 21799660
Err what delay? That was swift ;o)
0

Featured Post

Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
An article on effective troubleshooting
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question