|
Программирование >> Автоматически обновляемые приложения
listBoxl.Items.Add(String.Format( .NET Framework 2.0 installed? {0} , fx20Installed)); if (fx20Installed) { listBoxl.Items.Add(String.Format( .NET Framework 2.0 Exact Version: {0} , GetExactVersion(FrameworkVersion.Fx20))); listBoxl.Items.Add(String.Format( .NET Framework 2.0 Service Pack: {0} , GetServicePackLevel(FrameworkVersion.Fx20))); / <summary> / Определяет, установлена ли указанная версия .NET Framework / на локальном компьютере. / </summary> / <param name= frameworkVersion >OflHo из значений / <see cref= FrameworkVersion />.</param> / <returns><see langword= true /> если указанная версия .NET Framework / установлена; иначе <see langword= false />.</returns> public static bool Islnstalled(FrameworkVersion frameworkVersion) bool ret = false; private void buttonl Click(object sender, EventArgs e) { bool fxlllnstalled = Islnstalled(FrameworkVersion.Fxll); bool fx20Installed = Islnstalled(FrameworkVersion.Fx20); listBoxl.Items.Add(String.Format( .NET Framework 1.1 installed? {0} , fxlllnstalled)); if (fxlllnstalled) { listBoxl.Items.Add(String.Format( .NET Framework 1.1 Exact Version: {0} , GetExactVersion(FrameworkVersion.Fxll))); listBoxl.Items.Add(String.Format( .NET Framework 1.1 Service Pack: {0} , GetServicePackLevel(FrameworkVersion.Fxll))); return ret; private static bool IsNetfxllInstalledO { bool found = false; int regValue = 0; if (GetRegistryValue(RegistryHive.LocalMachine, Net fxlIRegKeyName, Netfxl1PlusRegValueName, RegistryValueKind.DWord, out regValue)) if (regValue == 1) { found = true; return found; private static bool IsNetfx20Installed() { bool found = false; int regValue = 0; if (GetRegistryValue(RegistryHive.LocalMachine, Net fx2ORegKeyName, Netfxl1PlusRegValueName, switch (frameworkVersion) { case FrameworkVersion.Fxll: ret = IsNetfxllInstalledO ; break; case FrameworkVersion.Fx20: ret = IsNetfx20Installed(); break; default: break; private static bool GetRegistryValue<T>(RegistryHive hive, string key, string value, RegistryValueKind kind, out T data) bool success = false; data = default(T); using (RegistryKey baseKey = RegistryKey.OpenRemoteBaseKey(hive. String.Empty)) if (baseKey != null) { using (RegistryKey registryKey = baseKey.OpenSubKey(key, RegistryKeyPermissionCheck.ReadSubTree)) if (registryKey != null) { Если ключ был открыт, попытаться извлечь значение. RegistryValueKind kindFound = registryKey.GetValueKind(value); if (kindFound == kind) { object regValue = registryKey.GetValue(value, null); if (regValue != null) { data = (T)Convert.ChangeType(regValue, typeof(T), Cultureinfo.InvariantCulture); success = true; RegistryValueKind.DWord, out regValue)) if (regValue ==1) { found = true; return found;
|
© 2006 - 2024 pmbk.ru. Генерация страницы: 0
При копировании материалов приветствуются ссылки. |