- Check Version (Windows)
- Contents
- Checking the version of Windows
- from wpkg package
- from batch file
- limitations
- Checking 32 or 64 bit
- from wpkg package
- from batch file
- notes
- Which version of Windows operating system am I running?
- Find operating system info in Windows 10
- Related links
- Find operating system info in Windows 8.1 or Windows RT 8.1
- Related links
- Find operating system info in Windows 7
- Related links
- How to check which version of Windows your computer is running
- Check out the products mentioned in this article:
- Windows 10 Home (From $139 at Best Buy)
- How to check which version of Windows you’re running
- How to get additional information about Windows 10
- How to get additional information about Windows 8
- Практическое руководство. Определение установленных версий платформы .NET Framework How to: Determine which .NET Framework versions are installed
- Определение реализации и версии .NET, в которой работает приложение Determine which .NET implementation and version an app is running on
- Обнаружение .NET Framework 4.5 и более поздних версий Detect .NET Framework 4.5 and later versions
- Минимальная версия Minimum version
- Использование редактора реестра Use Registry Editor
- Использование PowerShell для проверки минимальной версии Use PowerShell to check for a minimum version
- Отправка запросов в реестр с помощью кода Query the registry using code
- Обнаружение .NET Framework с 1.0 по 4.0 Detect .NET Framework 1.0 through 4.0
- Использование редактора реестра (более ранние версии платформы) Use Registry Editor (older framework versions)
- Запрос реестра с помощью кода (более ранние версии платформы) Query the registry using code (older framework versions)
- Поиск версий CLR Find CLR versions
Check Version (Windows)
This is not a complete installer package, it’s a collection of methods you can use to perform operations depending on the windows version you are using
Contents
Checking the version of Windows
The following examples show you how to determine which version of Windows you are running.
Note: since wpkg 1.2 you should better use Extended host attribute matching
from wpkg package
This approach can be used to limit a package to certain versions of windows; for example Windows7 already has Internet Explorer 8 installed, so to use a package in a mixed environment with xp and windows7 you could write a check like this:
The way this check works is that on Windows XP, wpkg would think that the package is already installed. This has a drawback: if you remove such a package, wpkg will try to remove this program every time on Windows XP systems, and then claim that the removal failed.
For more precise checks like Services Packs see also in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion the ProductName and CSDVersion fields. There is an example in the Windows XP SP3 silent installer.
from batch file
You now have a environment variable set to your version of Windows, which you can use to perform operations for a specific version, eg:
limitations
Windows 7 and Windows 2008 R2 are based on the same kernel, so both will show up as version 6.1
To find the edition of Windows (Home, Professional, Ultimate) you have to look at the EditionID Key in the Registry under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\. From a Batch file you’ll probably have to parse the output from the Systeminfo command.
Checking 32 or 64 bit
If you need to perform Install operations specific for 32bit or 64bit you can use the following checks
from wpkg package
Above example will return true on a 64bit System and the package will not install.
from batch file
notes
The environment variable ProgramW6432 is only defined in 64bit versions of Windows.
Be careful when using the PROCESSOR_ARCHITECTURE environment Variable or reading the value from HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE, as multiple processors can run 64bit OS, including AMD64, IA64 and «things to come».
Which version of Windows operating system am I running?
Find operating system info in Windows 10
To find out which version of Windows your device is running, press the Windows logo key + R, type winver in the Open box, and then select OK.
Here’s how to learn more:
Select the Start button > Settings > System > About .
Under Device specifications > System type, see if you’re running a 32-bit or 64-bit version of Windows.
Under Windows specifications, check which edition and version of Windows your device is running.
Related links
If you’re having a problem with activation, see Activate in Windows 10.
If you forgot the password you use to sign in to Windows devices or email, see How to reset your Microsoft password.
For info about updating Windows, see Windows Update: FAQ.
Find operating system info in Windows 8.1 or Windows RT 8.1
To find out which version of Windows your device is running, press the Windows logo key + R, type winver in the Open box, and then select OK.
If your device is running Windows 8.1 or Windows RT 8.1, here’s how to learn more:
If you’re using a touch device, swipe in from the right edge of the screen, tap Settings, and then tap Change PC settings. Continue to step 3.
If you’re using a mouse, point to the lower-right corner of the screen, move the mouse pointer up, click Settings, and then click Change PC settings.
Select PC and devices > PC info.
Under Windows you’ll see which edition and version of Windows your device is running.
Under PC > System type you’ll see if you’re running a 32-bit or 64-bit version of Windows.
Related links
If you’re having a problem with activation, see Activate Windows 7 or Windows 8.1
If you forgot the password you use to sign in to Windows devices or email, see How to reset your Microsoft password.
For info about updating Windows, see Windows Update: FAQ.
Find operating system info in Windows 7
Select the Start button, type Computer in the search box, right-click on Computer, and then select Properties.
Under Windows edition, you’ll see the version and edition of Windows that your device is running.
Support for Windows 7 ended on January 14, 2020
We recommend you move to a Windows 10 PC to continue to receive security updates from Microsoft.
Related links
If you’re having a problem with activation, see Activate Windows 7 or Windows 8.1.
If you forgot the password you use to sign in to Windows devices or email, see How to reset your Microsoft password.
For info about updating Windows, see Windows Update: FAQ.
How to check which version of Windows your computer is running
- If you need to check your version of Windows, you can find out by typing «winver» in the Start menu search box.
- Depending upon which version of Windows you have, you might also be able to open a window that displays additional information.
- This information is important if you have Windows 7, because support for that operating system ends in January 2020.
- Visit Business Insider’s homepage for more stories.
Do you know which version of Windows you’re running? Most of the time, there’s little reason to care. But sometimes you need to know. Some programs and computer hardware will only work with a specific version of Windows, for example.
You might also need to know if it’s time to upgrade. Microsoft generally supports each version of its operating system for about ten years, and «extended support» for Windows 7 ends on January 14, 2020 .
That means Microsoft won’t offer any updates or technical support after that date. If you have Windows 8, you have a little more time – support ends for that operating system on January 10, 2023.
Check out the products mentioned in this article:
Windows 10 Home (From $139 at Best Buy)
How to check which version of Windows you’re running
1. Click the Start button.
2. Type «winver» in the search box and press Enter.
3. You should see the About Windows box with your Windows version information.
If you want to know more than simply the version of the operating system, you can display a dialog box with additional information, but the process varies depending upon which version of the OS you are running.
How to get additional information about Windows 10
1. Click the Start button.
2. Click the Settings icon (which looks like a gear and is above the power icon).
3. Click «System.»
4. In the left pane, click «About.»
How to get additional information about Windows 8
1. Move the mouse to the lower-right corner of the screen and swipe it up to display the sidebar.
2. Click «Settings» and then click «Change PC settings.»
3. Click «PC and devices,» and then click «PC info.»
Практическое руководство. Определение установленных версий платформы .NET Framework How to: Determine which .NET Framework versions are installed
На компьютере можно установить и запустить несколько версий платформы .NET Framework. Users can install and run multiple versions of .NET Framework on their computers. При разработке или развертывании приложения могут потребоваться сведения о том, какие версии .NET Framework установлены на компьютере пользователя. When you develop or deploy your app, you might need to know which .NET Framework versions are installed on the user’s computer. Реестр содержит список версий .NET Framework, установленных на компьютере. The registry contains a list of the versions of .NET Framework installed on the computer.
Эта статья относится к .NET Framework. This article is specific to .NET Framework. Чтобы определить, какие пакеты SDK и среды выполнения .NET Core и .NET 5+ установлены, см. раздел Как проверить, что .NET уже установлен. To determine which .NET Core and .NET 5+ SDKs and runtimes are installed, see How to check that .NET is already installed.
Платформа .NET Framework состоит из двух основных компонентов, версии которым присваиваются отдельно: .NET Framework consists of two main components, which are versioned separately:
набор сборок, которые являются коллекциями типов и ресурсов, обеспечивающих функции приложений A set of assemblies, which are collections of types and resources that provide the functionality for your apps. (.NET Framework и сборкам назначается один номер версии); .NET Framework and the assemblies share the same version number. Например, версии .NET Framework включают в себя 4.5, 4.6.1 и 4.7.2. For example, .NET Framework versions include 4.5, 4.6.1, and 4.7.2.
среда CLR, которая выполняет код приложения и управляет им. The common language runtime (CLR), which manages and executes your app’s code. Одна версия среды CLR обычно поддерживает несколько версий .NET Framework. A single CLR version typically supports multiple .NET Framework versions. Например, CLR версии 4.0.30319.xxxxx, где xxxxx меньше 42000, поддерживает .NET Framework версий с 4 по 4.5.2. For example, CLR version 4.0.30319.xxxxx where xxxxx is less than 42000, supports .NET Framework versions 4 through 4.5.2. Версия CLR не менее 4.0.30319.42000 поддерживает версии .NET Framework начиная с .NET Framework 4.6. CLR version greater than or equal to 4.0.30319.42000 supports .NET Framework versions starting with .NET Framework 4.6.
Средства, поддерживаемые сообществом, помогают определить, какие версии .NET Framework установлены: Community-maintained tools are available to help detect which .NET Framework versions are installed:
Программа командной строки .NET Framework 2.0. A .NET Framework 2.0 command-line tool.
Модуль PowerShell 2.0. A PowerShell 2.0 module.
Сведения об определении установленных обновлений для каждой версии платформы .NET Framework см. в статье Практическое руководство. Определение установленных обновлений платформы .NET Framework. For information about detecting the installed updates for each version of .NET Framework, see How to: Determine which .NET Framework updates are installed.
Определение реализации и версии .NET, в которой работает приложение Determine which .NET implementation and version an app is running on
Для запроса реализации и версии .NET, в которой работает ваше приложение, можно использовать свойство RuntimeInformation.FrameworkDescription. You can use the RuntimeInformation.FrameworkDescription property to query for which .NET implementation and version your app is running on. Если приложение работает в .NET Framework, выходные данные будут выглядеть примерно так: If the app is running on .NET Framework, the output will be similar to:
Если же приложение работает в .NET Core или .NET 5+, выходные данные будут выглядеть следующим образом: By comparison, if the app is running on .NET Core or .NET 5+, the output will be similar to:
Обнаружение .NET Framework 4.5 и более поздних версий Detect .NET Framework 4.5 and later versions
Версия .NET Framework (4.5 и более поздние), установленная на компьютере, указана в реестре в HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full. The version of .NET Framework (4.5 and later) installed on a machine is listed in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full. Если отсутствует подраздел Full, то .NET Framework 4.5 или более поздней версии не установлен. If the Full subkey is missing, then .NET Framework 4.5 or above isn’t installed.
Подраздел NET Framework Setup в пути реестра не начинается с точки. The NET Framework Setup subkey in the registry path does not begin with a period.
Значение Release REG_DWORD в реестре представляет установленную версию .NET Framework. The Release REG_DWORD value in the registry represents the version of .NET Framework installed.
Версия платформы .NET Framework .NET Framework version | Значение Release Value of Release |
---|---|
.NET Framework 4,5 .NET Framework 4.5 | Все версии операционной системы Windows: 378389 All Windows operating systems: 378389 |
.NET Framework 4.5.1 .NET Framework 4.5.1 | Windows 8.1 и Windows Server 2012 R2: 378675 On Windows 8.1 and Windows Server 2012 R2: 378675 Все другие версии операционной системы Windows: 378758 On all other Windows operating systems: 378758 |
.NET Framework 4.5.2 .NET Framework 4.5.2 | Все версии операционной системы Windows: 379893 All Windows operating systems: 379893 |
.NET Framework 4.6 .NET Framework 4.6 | Windows 10: 393295 On Windows 10: 393295 Все другие версии операционной системы Windows: 393297 On all other Windows operating systems: 393297 |
.NET Framework 4.6.1 .NET Framework 4.6.1 | Windows 10 с ноябрьским обновлением: 394254 On Windows 10 November Update systems: 394254 Все остальные версии операционной системы Windows (включая Windows 10): 394271 On all other Windows operating systems (including Windows 10): 394271 |
.NET Framework 4.6.2 .NET Framework 4.6.2 | В юбилейном обновлении Windows 10 и Windows Server 2016: 394802 On Windows 10 Anniversary Update and Windows Server 2016: 394802 Все остальные версии операционной системы Windows (включая другие операционные системы Windows 10): 394806 On all other Windows operating systems (including other Windows 10 operating systems): 394806 |
.NET Framework 4.7 .NET Framework 4.7 | Windows 10 Creators Update: 460798 On Windows 10 Creators Update: 460798 Все остальные версии операционной системы Windows (включая другие операционные системы Windows 10): 460805 On all other Windows operating systems (including other Windows 10 operating systems): 460805 |
.NET Framework 4.7.1 .NET Framework 4.7.1 | Windows 10 Fall Creators Update и Windows Server версии 1709: 461308 On Windows 10 Fall Creators Update and Windows Server, version 1709: 461308 Все остальные версии операционной системы Windows (включая другие операционные системы Windows 10): 461310 On all other Windows operating systems (including other Windows 10 operating systems): 461310 |
.NET Framework 4.7.2 .NET Framework 4.7.2 | Windows 10 за апрель 2018 г. Update и Windows Server версии 1803: 461808 On Windows 10 April 2018 Update and Windows Server, version 1803: 461808 Все остальные операционные системы, кроме Windows 10 с обновлением за апрель 2018 г. и Windows Server версии 1803: 461814 On all Windows operating systems other than Windows 10 April 2018 Update and Windows Server, version 1803: 461814 |
.NET Framework 4.8 .NET Framework 4.8 | Обновление Windows 10 за май 2019 года и обновление Windows 10 за ноябрь 2019 года: 528040 On Windows 10 May 2019 Update and Windows 10 November 2019 Update: 528040 Обновление Windows 10 за май 2020 года и обновление Windows 10 за октябрь 2020 года: 528372 On Windows 10 May 2020 Update and Windows 10 October 2020 Update: 528372 Все остальные версии операционной системы Windows (включая другие операционные системы Windows 10): 528049 On all other Windows operating systems (including other Windows 10 operating systems): 528049 |
Минимальная версия Minimum version
Чтобы определить, присутствует ли минимальная версия .NET Framework, проверьте значение Release REG_DWORD, которое больше или равно соответствующему значению, указанному в следующей таблице. To determine whether a minimum version of .NET Framework is present, check for a Release REG_DWORD value that’s greater than or equal to the corresponding value listed in the following table. Например, если приложение работает в .NET Framework 4.8 или более поздней версии, проверьте, является ли значение REG_DWORD Release большим или равным 528040. For example, if your application runs under .NET Framework 4.8 or a later version, test for a Release REG_DWORD value that’s greater than or equal to 528040.
Версия платформы .NET Framework .NET Framework version | Минимальное значение Minimum value |
---|---|
.NET Framework 4,5 .NET Framework 4.5 | 378389 378389 |
.NET Framework 4.5.1 .NET Framework 4.5.1 | 378675 378675 |
.NET Framework 4.5.2 .NET Framework 4.5.2 | 379893 379893 |
.NET Framework 4.6 .NET Framework 4.6 | 393295 393295 |
.NET Framework 4.6.1 .NET Framework 4.6.1 | 394254 394254 |
.NET Framework 4.6.2 .NET Framework 4.6.2 | 394802 394802 |
.NET Framework 4.7 .NET Framework 4.7 | 460798 460798 |
.NET Framework 4.7.1 .NET Framework 4.7.1 | 461308 461308 |
.NET Framework 4.7.2 .NET Framework 4.7.2 | 461808 461808 |
.NET Framework 4.8 .NET Framework 4.8 | 528040 528040 |
Использование редактора реестра Use Registry Editor
В меню Пуск выберите Выполнить, введите regedit и нажмите кнопку ОК. From the Start menu, choose Run, enter regedit, and then select OK.
(Для запуска программы regedit необходимы учетные данные администратора.) (You must have administrative credentials to run regedit.)
В редакторе реестра откройте следующий подраздел: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full. In the Registry Editor, open the following subkey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full. Если подраздел Full отсутствует, платформа .NET Framework 4.5 или более поздней версии не установлена. If the Full subkey isn’t present, then you don’t have .NET Framework 4.5 or later installed.
Проверьте значение REG_DWORD с именем Release. Check for a REG_DWORD entry named Release. Если оно имеется, платформа .NET Framework 4.5 или более поздней версии установлена. If it exists, then you have .NET Framework 4.5 or later installed. Это значение соответствует определенной версии .NET Framework. Its value corresponds to a particular version of .NET Framework. Например, на приведенном ниже рисунке значение параметра Release равно 528040, что является разделом выпуска для .NET Framework 4.8. In the following figure, for example, the value of the Release entry is 528040, which is the release key for .NET Framework 4.8.
Использование PowerShell для проверки минимальной версии Use PowerShell to check for a minimum version
Используйте команды PowerShell для проверки значения параметра Release в подразделе HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full. Use PowerShell commands to check the value of the Release entry of the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full subkey.
В приведенных ниже примерах значение Release проверяется с целью определить, установлена ли версия 4.6.2 или более поздняя версия .NET Framework. The following examples check the value of the Release entry to determine whether .NET Framework 4.6.2 or later is installed. Код возвращает значение True , если одна из таких версий установлена, и False в противном случае. This code returns True if it’s installed and False otherwise.
Отправка запросов в реестр с помощью кода Query the registry using code
Используйте методы RegistryKey.OpenBaseKey и RegistryKey.OpenSubKey для доступа к подразделу HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full в реестре Windows. Use the RegistryKey.OpenBaseKey and RegistryKey.OpenSubKey methods to access the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full subkey in the Windows registry.
Если вы используете 32-разрядное приложение в 64-разрядной версии Windows, пути реестра будут отличаться от указанных ранее. If the app you’re running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed. 64-разрядный реестр доступен в подразделе HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ . The 64-bit registry is available in the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ subkey. Например, подразделом реестра для .NET Framework 4.5 является HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4\Full. For example, the registry subkey for .NET Framework 4.5 is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4\Full.
Проверьте значение REG_DWORD Release, чтобы определить установленную версию. Check the Release REG_DWORD value to determine the installed version. Для обеспечения совместимости с последующими версиями значение должно быть больше или равно значению, указанному в таблице версий .NET Framework. To be forward-compatible, check for a value greater than or equal to the value listed in the .NET Framework version table.
В следующем примере проверяется значение Release в реестре для поиска установленных версий .NET Framework 4.5–4.8. The following example checks the value of the Release entry in the registry to find the versions of .NET Framework 4.5-4.8 that are installed:
Этот пример выводит данные, подобные следующим: The example displays output like the following:
В этом примере применяются рекомендации для проверки версии: This example follows the recommended practice for version checking:
- Проверяется, имеет ли параметр Release значение, большее или равное значению известных разделов выпуска. It checks whether the value of the Release entry is greater than or equal to the value of the known release keys.
- Проверка выполняется с самой последней до самой ранней версии. It checks in order from most recent version to earliest version.
Обнаружение .NET Framework с 1.0 по 4.0 Detect .NET Framework 1.0 through 4.0
Каждая версия .NET Framework с 1.1 по 4.0 указана в виде подраздела в HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP. Each version of .NET Framework from 1.1 to 4.0 is listed as a subkey at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP. В следующей таблице перечислены пути к каждой версии .NET Framework. The following table lists the path to each .NET Framework version. Для большинства версий существует значение REG_DWORD Install, равное 1 , чтобы указать, что эта версия установлена. For most versions, there’s an Install REG_DWORD value of 1 to indicate this version is installed. В этих подразделах также имеется значение REG_SZ Version, содержащее строку версии. In these subkeys, there’s also a Version REG_SZ value that contains a version string.
Подраздел NET Framework Setup в пути реестра не начинается с точки. The NET Framework Setup subkey in the registry path does not begin with a period.
Версия платформы Framework Version | Подраздел реестра Registry Subkey | Значение Value |
---|---|---|
1.0 1.0 | HKLM\Software\Microsoft\.NETFramework\Policy\v1.0\3705 HKLM\Software\Microsoft\.NETFramework\Policy\v1.0\3705 | REG_SZ Install равно 1 Install REG_SZ equals 1 |
1.1 1.1 | HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322 | REG_DWORD Install равно 1 Install REG_DWORD equals 1 |
2.0 2.0 | HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727 | REG_DWORD Install равно 1 Install REG_DWORD equals 1 |
3.0 3.0 | HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup | Значение REG_DWORD InstallSuccess равно 1 InstallSuccess REG_DWORD equals 1 |
3.5 3.5 | HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5 | REG_DWORD Install равно 1 Install REG_DWORD equals 1 |
Клиентский профиль 4.0 4.0 Client Profile | HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client | REG_DWORD Install равно 1 Install REG_DWORD equals 1 |
Полный профиль 4.0 4.0 Full Profile | HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full | REG_DWORD Install равно 1 Install REG_DWORD equals 1 |
Если вы используете 32-разрядное приложение в 64-разрядной версии Windows, пути реестра будут отличаться от указанных ранее. If the app you’re running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed. 64-разрядный реестр доступен в подразделе HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ . The 64-bit registry is available in the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ subkey. Например, подразделом реестра для .NET Framework 3.5 является HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v3.5. For example, the registry subkey for .NET Framework 3.5 is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v3.5.
Обратите внимание, что путь реестра к подразделу .NET Framework 1.0 отличается от остальных. Notice that the registry path to the .NET Framework 1.0 subkey is different from the others.
Использование редактора реестра (более ранние версии платформы) Use Registry Editor (older framework versions)
В меню Пуск выберите Выполнить, введите regedit и нажмите кнопку ОК. From the Start menu, choose Run, enter regedit, and then select OK.
Для запуска программы regedit необходимы учетные данные администратора. You must have administrative credentials to run regedit.
Откройте подраздел, соответствующий версии, которую необходимо проверить. Open the subkey that matches the version you want to check. Используйте таблицу в разделе Обнаружение .NET Framework с 1.0 по 4.0. Use the table in the Detect .NET Framework 1.0 through 4.0 section.
На приведенном ниже рисунке показан подраздел для версии .NET Framework 3.5 вместе со значением Version. The following figure shows the subkey and its Version value for .NET Framework 3.5.
Запрос реестра с помощью кода (более ранние версии платформы) Query the registry using code (older framework versions)
Используйте класс Microsoft.Win32.RegistryKey для доступа к подразделу HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP в реестре Windows. Use the Microsoft.Win32.RegistryKey class to access the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP subkey in the Windows registry.
Если вы используете 32-разрядное приложение в 64-разрядной версии Windows, пути реестра будут отличаться от указанных ранее. If the app you’re running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed. 64-разрядный реестр доступен в подразделе HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ . The 64-bit registry is available in the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ subkey. Например, подразделом реестра для .NET Framework 3.5 является HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v3.5. For example, the registry subkey for .NET Framework 3.5 is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v3.5.
В следующем примере ищутся установленные версии .NET Framework 1–4: The following example finds the versions of .NET Framework 1-4 that are installed:
В этом примере отобразятся выходные данные, аналогичные следующим: The example displays output similar to the following:
Поиск версий CLR Find CLR versions
.NET Framework CLR, установленный с .NET Framework, имеет отдельную версию. The .NET Framework CLR installed with .NET Framework is versioned separately. Есть два способа определить версию среды выполнения .NET Framework CLR: There are two ways to detect the version of the .NET Framework CLR:
Инструмент Clrver.exe The Clrver.exe tool
Для определения версий среды CLR, установленных на компьютере, можно использовать средство CLR Version (Clrver.exe). Use the CLR Version tool (Clrver.exe) to determine which versions of the CLR are installed on a computer. Откройте Командную строку разработчика или PowerShell для разработчиков в Visual Studio и введите clrver . Open Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell and enter clrver .
Пример результатов выполнения: Sample output:
Класс Environment The Environment class
Для .NET Framework 4.5 и более поздних версий не следует использовать свойство Environment.Version для определения версии среды CLR. For .NET Framework 4.5 and later versions, don’t use the Environment.Version property to detect the version of the CLR. Вместо этого выполните запрос к реестру, как описано в разделе Обнаружение .NET Framework 4.5 и более поздних версий. Instead, query the registry as described in Detect .NET Framework 4.5 and later versions.
Выполните запрос к свойству Environment.Version, чтобы получить объект Version. Query the Environment.Version property to retrieve a Version object.
Возвращенный объект System.Version указывает версию среды выполнения, в которой в настоящее время выполняется код. The returned System.Version object identifies the version of the runtime that’s currently executing the code. Он не содержит версий сборок или других версий среды выполнения, которые установлены на компьютере. It doesn’t return assembly versions or other versions of the runtime that may have been installed on the computer.
Для платформы .NET Framework версий 4, 4.5, 4.5.1 и 4.5.2 возвращаемый объект Version имеет строковое представление 4.0.30319.xxxxx, где xxxxx меньше 42000. For .NET Framework versions 4, 4.5, 4.5.1, and 4.5.2, the string representation of the returned Version object has the form 4.0.30319.xxxxx, where xxxxx is less than 42000. Для .NET Framework 4.6 и более поздних версий оно имеет форму 4.0.30319.42000. For .NET Framework 4.6 and later versions, it has the form 4.0.30319.42000.
Получив объект Version, выполните к нему запрос: After you have the Version object, query it as follows:
Чтобы получить идентификатор основного выпуска (например, 4 в случае версии 4.0), используйте свойство Version.Major. For the major release identifier (for example, 4 for version 4.0), use the Version.Major property.
Чтобы получить идентификатор дополнительной версии (например, 0 в случае версии 4.0), используйте свойство Version.Minor. For the minor release identifier (for example, 0 for version 4.0), use the Version.Minor property.
Чтобы получить всю строку версии (например, 4.0.30319.18010), используйте метод Version.ToString. For the entire version string (for example, 4.0.30319.18010), use the Version.ToString method. Он возвращает одно значение, соответствующее версии среды выполнения, в которой выполняется код. This method returns a single value that reflects the version of the runtime that’s executing the code. Он не возвращает версий сборок или других версий среды выполнения, которые установлены на компьютере. It doesn’t return assembly versions or other runtime versions that may be installed on the computer.
В следующем примере свойство Environment.Version используется для получения сведений о версии среды CLR: The following example uses the Environment.Version property to retrieve CLR version information:
В этом примере отобразятся выходные данные, аналогичные следующим: The example displays output similar to the following: