CodeNet / Платформы / Windows / Реестр
Как определить версию IE?
Источник: www.rsdn.ru
Способ 1
Версия IE, начиная с IE4, хранится в реестре Windows. Чтобы получить к ней доступ, необходимо открыть ключ:
HKEY_LOCAL_MACHINE Software Microsoft Internet Explorer
и прочитать значение Version под этим ключом. Version - это строка в формате:
<major version>.<minor version>.<build number>.<sub-build number>
Функция, которая читает версию IE из реестра, может выглядеть примерно так.
#include <atlbase.h>
BOOL GetIEVersion(DWORD *pMajor, DWORD *pMinor, DWORD *pBuild, DWORD *pSubBuild)
{
CRegKey rk;
LONG lRet = rk.Open(HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\Internet Explorer"), KEY_READ);
if(lRet == 0)
{
TCHAR szBuff[256];
DWORD dwCount = sizeof(szBuf);
lRet = rk.QueryValue(szBuff, _T("Version"), &dwCount);
if(lRet == 0)
{
sscanf(szBuff, "%u.%u.%u.%u", pMajor, pMinor, pBuild, pSubBuild);
return TRUE;
}
}
return FALSE;
}
ПРИМЕЧАНИЕ
Для простоты я воспользовался для работы с реестром классом CRegKey из библиотеки ATL.
Чтобы определить версию IE в более привычном виде, можно использовать следующую таблицу соответствия.
| Версия | Продукт |
| 4.40.308 | Internet Explorer 1.0 (Plus!) |
| 4.40.520 | Internet Explorer 2.0 |
| 4.70.1155 | Internet Explorer 3.0 |
| 4.70.1158 | Internet Explorer 3.0 (OSR2) |
| 4.70.1215 | Internet Explorer 3.01 |
| 4.70.1300 | Internet Explorer 3.02 and 3.02a |
| 4.71.544 | Internet Explorer 4.0 Platform Preview 1.0 (PP1) |
| 4.71.1008.3 | Internet Explorer 4.0 Platform Preview 2.0 (PP2) |
| 4.71.1712.6 | Internet Explorer 4.0 |
| 4.72.2106.8 | Internet Explorer 4.01 |
| 4.72.3110.8 | Internet Explorer 4.01 Service Pack 1 (SP1) |
| 4.72.3612.1713 | Internet Explorer 4.01 Service Pack 2 (SP2) |
| 5.00.0518.10 | Internet Explorer 5 Developer Preview (Beta 1) |
| 5.00.0910.1309 | Internet Explorer 5 Beta (Beta 2) |
| 5.00.2014.0216 | Internet Explorer 5 |
| 5.00.2314.1003 | Internet Explorer 5 (Office 2000) |
| 5.00.2614.3500 | Internet Explorer 5 (Windows 98 Second Edition) |
| 5.00.2516.1900 | Internet Explorer 5.01 (Windows 2000 Beta 3, build 5.00.2031) |
| 5.00.2919.800 | Internet Explorer 5.01 (Windows 2000 RC1, build 5.00.2072) |
| 5.00.2919.3800 | Internet Explorer 5.01 (Windows 2000 RC2, build 5.00.2128) |
| 5.00.2919.6307 | Internet Explorer 5.01 (Also included with Office 2000 SR-1, but not installed by default) |
| 5.00.2920.0000 | Internet Explorer 5.01 (Windows 2000, build 5.00.2195) |
| 5.00.3103.1000 | Internet Explorer 5.01 SP1 (Windows 2000) |
| 5.00.3105.0106 | Internet Explorer 5.01 SP1 (Windows 95/98 and Windows NT 4.0) |
| 5.00.3314.2101 | Internet Explorer 5.01 SP2 (Windows 95/98 and Windows NT 4.0) |
| 5.00.3315.1000 | Internet Explorer 5.01 SP2 (Windows 2000) |
| 5.50.3825.1300 | Internet Explorer 5.5 Developer Preview (Beta) |
| 5.50.4030.2400 | Internet Explorer 5.5 & Internet Tools Beta |
| 5.50.4134.0100 | Windows Me (4.90.3000) |
| 5.50.4134.0600 | Internet Explorer 5.5 |
| 5.50.4308.2900 | Internet Explorer 5.5 Advanced Security Privacy Beta |
| 5.50.4522.1800 | Internet Explorer 5.5 Service Pack 1 |
| 5.50.4807.2300 | Internet Explorer 5.5 Service Pack 2 |
| 6.00.2462.0000 | Internet Explorer 6 Public Preview (Beta) |
| 6.00.2479.0006 | Internet Explorer 6 Public Preview (Beta) Refresh |
| 6.00.2600.0000 | Internet Explorer 6 |
Способ 2
Чтобы определить версию библиотеки shdocvw.dll, необходимо загрузить её с помощью LoadLibrary, а затем вызвать из неё функцию DllGetVersion. Поскольку эта DLL находится в системном каталоге Windows, функции LoadLibrary достаточно передать её имя (без пути). Вот пример функции, которая определяет версию shdocvw.dll.
#include <windows.h>
#include <shlwapi.h>
BOOL GetIEVersion(DWORD *pMajor, DWORD *pMinor, DWORD *pBuild)
{
BOOL bRes = FALSE;
HMODULE hDll = LoadLibrary(_T("shdocvw.dll"));
if(hDll)
{
DLLGETVERSIONPROC pDllGetVersion;
pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hDll, _T("DllGetVersion"));
if(pDllGetVersion)
{
DLLVERSIONINFO dvi;
ZeroMemory(&dvi, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
HRESULT hr = pDllGetVersion(&dvi);
if(SUCCEEDED(hr))
{
*pMajor = dvi.dwMajorVersion;
*pMinor = dvi.dwMinorVersion;
*pBuild = dvi.dwBuildNumber;
bRes = TRUE;
}
}
FreeLibrary(hDll);
}
return bRes;
}
Вот таблица соответствия версий IE и версий библиотеки shdocvw.dll.
| Версия | Продукт |
| 4.70.1155 | Internet Explorer 3.0 |
| 4.70.1158 | Internet Explorer 3.0 (OSR2) |
| 4.70.1215 | Internet Explorer 3.01 |
| 4.70.1300 | Internet Explorer 3.02 and 3.02a |
| 4.71.1008.3 | Internet Explorer 4.0 PP2 |
| 4.71.1712.5 | Internet Explorer 4.0 |
| 4.72.2106.7 | Internet Explorer 4.01 |
| 4.72.3110.3 | Internet Explorer 4.01 Service Pack 1 |
| 4.72.3612.1707 | Internet Explorer 4.01 SP2 |
| 4.72.3711.2900 | Internet Explorer 4.x with Update for "Server-side Page Reference Redirect" Issue installed. |
| 5.00.0518.5 | Internet Explorer 5 Developer Preview (Beta 1) |
| 5.00.0910.1308 | Internet Explorer 5 Beta (Beta 2) |
| 5.00.2014.213 | Internet Explorer 5 |
| 5.00.2314.1000 | Internet Explorer 5 (Office 2000) |
| 5.00.2516.1900 | Internet Explorer 5.01 (Windows 2000 Beta 3, build 5.00.2031) |
| 5.00.2614.3500 | Internet Explorer 5 (Windows 98 Second Edition) |
| 5.00.2717.2000 | Internet Explorer 5 with Update for "Malformed Favorites Icon" Security Issue installed. |
| 5.00.2721.1400 | Internet Explorer 5 with Update for "ImportExport Favorites()" Security Issue installed. |
| 5.00.2723.2900 | Internet Explorer 5.0 with Update for "Server-side Page Reference Redirect" Issue installed. |
| 5.00.2919.800 | Internet Explorer 5.01 (Windows 2000 RC1, build 5.00.2072) |
| 5.00.2919.3800 | Internet Explorer 5.01 (Windows 2000 RC2, build 5.00.2128) |
| 5.00.2919.6307 | Internet Explorer 5.01 (Also included with Office 2000 SR-1, but not installed by default) |
| 5.00.2919.6400 | Internet Explorer 5.01 with Update for "Server-side Page Reference Redirect" Issue installed. |
| 5.00.2920.0000 | Internet Explorer 5.01 (Windows 2000, build 5.00.2195) |
| 5.00.3103.1000 | Internet Explorer 5.01 SP1 (Windows 2000) |
| 5.00.3105.0106 | Internet Explorer 5.01 SP1 (Windows 95/98 and Windows NT 4.0) |
| 5.00.3314.2100 | Internet Explorer 5.01 SP2 (Windows 95/98 and Windows NT 4.0) |
| 5.00.3315.2879 | Internet Explorer 5.01 SP2 (Windows 2000) |
| 5.50.3825.1300 | Internet Explorer 5.5 Developer Preview (Beta) |
| 5.50.4030.2400 | Internet Explorer 5.5 & Internet Tools Beta |
| 5.50.4134.0100 | Windows Me (4.90.3000) |
| 5.50.4134.0600 | Internet Explorer 5.5 |
| 5.50.4308.2900 | Internet Explorer 5.5 Advanced Security Privacy Beta |
| 5.50.4522.1800 | Internet Explorer 5.5 Service Pack 1 |
| 5.50.4807.2300 | Internet Explorer 5.5 Service Pack 2 |
| 6.00.2462.0000 | Internet Explorer 6 Public Preview (Beta) |
| 6.00.2479.0006 | Internet Explorer 6 Public Preview (Beta) Refresh |
| 6.00.2600.0000 | Internet Explorer 6 |
ПРИМЕЧАНИЕ
Как показывает практика, иногда встречаются "экзотические" версии IE, у которых Build Number отличается от приведённых в таблице. Поэтому старайтесь по возможности ориентироваться только на номер версии.
Оставить комментарий
Комментарии


(данная история касаема второго способа)
итак стоит XPHome, SP2, после очередного автоапдейта у меня установилась 7.0.5730.11 версия МС Эксплорера, но вышеуказаная библиотека (shdocvw.dll) и некоторые другие, какие обычно народ предлагает на проверку (например shlwapi.dll) остались с версией 6 (6.0.2900.3020).
Так что имейте ввиду.
За сим откланяюсь. :)
