How To Interpret the Results of InternetQueryOption with the INTERNET_VERSION_INFO Structure (244857)
The information in this article applies to:
- Microsoft Internet Explorer (Programming) 3.0
- Microsoft Internet Explorer (Programming) 4.0
- Microsoft Internet Explorer (Programming) 5
- Microsoft Windows Internet Services (WinInet)
This article was previously published under Q244857 SUMMARY
Using the InternetQueryOption function, you can retrieve the version of the WinInet DLL. The version information returned is the internal version number of the DLL not the version stamp of the WinInet.dll file.
MORE INFORMATION
You can use the INTERNET_VERSION_INFO structure as follows (error checking code is omitted):
INTERNET_VERSION_INFO structVI;
DWORD dwStructSize = sizeof(INTERNET_VERSION_INFO);
InternetQueryOption (NULL, INTERNET_OPTION_VERSION,
(LPVOID)&structVI, &dwStructSize);
printf("WinINet Major Version: %d\n", structVI.dwMajorVersion);
printf("WinINet Minor Version: %d\n", structVI.dwMinorVersion);
The Platform SDK contains the following description of the INTERNET_OPTION_VERSION flag that can be used with the InternetQueryOption function:
Retrieves an INTERNET_VERSION_INFO structure that contains the version number of Wininet.dll. This option can be used on a NULL HINTERNET handle by InternetQueryOption.
The INTERNET_VERSION_INFO structure returned by this function call can be interpreted as follows:
|
1 | 0 | Internet Explorer 3 | 1 | 1 | Internet Explorer 4 | 1 | 2 | Internet Explorer 5 |
It is possible to get exact Wininet.dll version information (as shown in file properties) by using version APIs as follows:
#define SWAPWORDS(X) ( (X<<16) | (X>>16) )
...
if (! (dwSize = GetFileVersionInfoSize (TEXT("wininet.dll"), &dwHandle) ) )
{
dwError = GetLastError();
if (dwError == 2)
// 2 is file no found error
cerr << "Wininet.dll is not found" << endl;
else if (dwError == 1812)<BR/>
// 1812 means no resource section information, very unlikely case
cerr << "Wininet.dll does contain resource section" << endl;
else
cerr << "GetFileVersionInfoSize failed: " <<
GetLastError() << endl;
return 0;
}
lpBuffer = new TCHAR [dwSize];
if (!GetFileVersionInfo (TEXT ("wininet.dll"), 0,
dwSize, (LPVOID) lpBuffer) )
{
cerr << "GetFileVersionInfo failed: "
<< GetLastError() << endl;
return 0;
}
LPDWORD lpdwLangCp;
if (!VerQueryValue(lpBuffer, TEXT("\\VarFileInfo\\Translation"),
(LPVOID*) &lpdwLangCp, &dwUint) )
{
cerr << "VerQueryValue failed: " << GetLastError() << endl;
return 0;
}
TCHAR szLangCp[9];
wsprintf( szLangCp, TEXT ("%08X"),SWAPWORDS( *lpdwLangCp ));
TCHAR SubBlock [2048];
wsprintf( SubBlock, TEXT("\\StringFileInfo\\%s\\FileVersion"), szLangCp );
if (!VerQueryValue(lpBuffer, SubBlock, (LPVOID*)&Buffer, &dwUint) )
{
cerr << "No file version info available" << endl;
return 0;
}
else
cout << "File Version: " << Buffer << endl;
wsprintf( SubBlock, TEXT("\\StringFileInfo\\%s\\ProductVersion"),
szLangCp );
if (!VerQueryValue(lpBuffer, SubBlock, (LPVOID*)&Buffer, &dwUint) )
{
cerr << "No produce version info available" << endl;
return 0;
}
else
cout << "Product Version: " << Buffer << endl;
wsprintf( SubBlock, TEXT("\\StringFileInfo\\%s\\FileDescription"),
szLangCp );
if (!VerQueryValue(lpBuffer, SubBlock, (LPVOID*)&Buffer, &dwUint) )
{
cerr << "No File Description info available" << endl;
return 0;
}
else
cout << "File Description: " << Buffer << endl;
delete [] lpBuffer;
Modification Type: | Minor | Last Reviewed: | 7/2/2004 |
---|
Keywords: | kbhowto KB244857 |
---|
|