Get Version of Internet Explorer from Shdocvw.dll

I am working on writing a function that is capable of detecting the version of Internet Explorer that is installed.  I have already written one that retrives the information from the HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer registry key.  That was fairly easy.  Now I would like to take on a considerably more difficult and more accurate approach to resolve the same problem, obtaining the information directly from shdocvw.dll located in the system directory.

I know that I need to use GetSystemDirectory ( , ) to obtain the system directory information.  Then I need to determine if shdocvw.dll exists in the system directory.  I believe that I can accomplish this by creating a _finddata_t structure using _findfirst to find the file.  If _findfirst fails, I know that IE is not installed.

My questions begin with what comes next.  I have read the documentation on the GetFileVersionInfo ( , , , ) function that is available in the MSDN library and find it to be confusing at best.  I also am disappointed by the lack of example code for the GetFileVersionInfo API.  Since I want my function to be usable in Windows 95 on up, I know that I cannot use the simpler DllGetVersion function.

Does anyone have some example code on how to use the GetFileVersionInfo ( , , , ) function or some code illustrating how to accomplish the goal of obtaining the Internet Explorer version shdocvw.dll?  Even just clarification on how to use the GetFileVersionInfo ( , , , ) function will be helpfull.
Who is Participating?
snoeglerConnect With a Mentor Commented:
Hello Bkey1,

I've been using the function below for a similar task.
It takes the name of the DLL (located in the system directory) and returns the version number in 'v1','v2','v3','v4'.

**  FUNCTION:   GetVersionInfo()
**  RETURNS:    <bool>
**  PURPOSE:    Returns the version no. of 'shdocvw.dll'
bool    GetVersionInfo(LPCTSTR lpszDLL, int& v1,int& v2,int& v3,int& v4)
    char            szBuffer[_MAX_PATH];
    char            szTemp[_MAX_PATH];


    DWORD           dwZero,dwSize;
    dwSize          =GetFileVersionInfoSize(szTemp,&dwZero);
        return false;

    unsigned char   *pvdata=new unsigned char[dwSize];
    if(GetFileVersionInfo(szTemp,NULL,dwSize,pvdata)==FALSE) {
        delete pvdata;
        return false;

    UINT            nVerLen;

    if(VerQueryValue(pvdata,"\\",(LPVOID*)&pvfi,&nVerLen)==FALSE) {
        delete pvdata;
        return false;

    v1              =HIWORD(pvfi->dwFileVersionMS);
    v2              =LOWORD(pvfi->dwFileVersionMS);
    v3              =HIWORD(pvfi->dwFileVersionLS);
    v4              =LOWORD(pvfi->dwFileVersionLS);

    delete pvdata;

    return true;

Hope that helped,

Bkey1Author Commented:
This helps alot.  Thank you very much.  I am especially glad that this function does not require MFC, it can be used in an application based on the Win32 API.  I am also pleased to see that it is well organized, easily understood code.
Thanks :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.