您可以使用 InternetQueryOption 函数检索 WinInet DLL 的版本。返回的版本信息不是版本标记 WinInet.dll 文件的 DLL 的内部版本号。
您可以使用 INTERNET_VERSION_INFO 结构 (省略检查代码错误) 如下:
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);
dwMajorVersion | dwMinorVersion | WinInet 版本 |
---|---|---|
1 | 0 | Internet 3 Explorer |
1 | 1 | Internet 4 Explorer |
1 | 2 | Internet 5 Explorer |
可以通过使用版本的 api,如下所示获得精确的 Wininet.dll 版本信息 (如文件属性中所示):
#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;