Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void CheckFramework()
- {
- int releaseKey = CUtils.GetDotNetVersionFromRegistry();
- string releaseText = CUtils.GetDotNetVersionString(releaseKey);
- CLog.WriterFormatLog(PathLogBase, $"Net Framework installed: {releaseText} ({releaseKey})", EtypeLog.Info);
- if (releaseKey < CUtils.VERSION_46)
- {
- MessageBox.Show("Su questa postazione non risulta installato il NET Framework versione 4.6 o successive, necessari per una ottimale navigabilità dei siti Web. Per l’aggiornamento del NET Framework, si consiglia di contattare il centro specializzato.", "ATTENZIONE:");
- }
- }
- internal static int GetDotNetVersionFromRegistry()
- {
- int releaseKey = 0;
- using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\"))
- {
- releaseKey = Convert.ToInt32(ndpKey.GetValue("Release"));
- }
- return releaseKey;
- }
- internal static string GetDotNetVersionString(int releaseKey)
- {
- if (releaseKey >= VERSION_48)
- {
- return "4.8 or later";
- }
- if (releaseKey >= VERSION_472)
- {
- return "4.7.2 or later";
- }
- if (releaseKey >= VERSION_471)
- {
- return "4.7.1 or later";
- }
- if (releaseKey >= VERSION_47)
- {
- return "4.7 or later";
- }
- if (releaseKey >= VERSION_462)
- {
- return "4.6.2 or later";
- }
- if (releaseKey >= VERSION_461)
- {
- return "4.6.1 or later";
- }
- if (releaseKey >= VERSION_46)
- {
- return "4.6 or later";
- }
- if (releaseKey >= VERSION_46RC)
- {
- return "4.6 RC or later";
- }
- if ((releaseKey >= VERSION_452))
- {
- return "4.5.2 or later";
- }
- if ((releaseKey >= VERSION_451))
- {
- return "4.5.1 or later";
- }
- if ((releaseKey >= VERSION_45))
- {
- return "4.5 or later";
- }
- // This line should never execute. A non-null release key should mean
- // that 4.5 or later is installed.
- return "No 4.5 or later version detected";
- }
- internal static bool AdobeInstalled(out string pPath)
- {
- pPath = string.Empty;
- string sKey = string.Empty;
- bool bInstalled = false;
- RegistryKey adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe");
- if (adobe == null)
- {
- var policies = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Policies");
- if (policies != null)
- adobe = policies.OpenSubKey("Adobe");
- }
- if (adobe != null)
- {
- RegistryKey acroRead = adobe.OpenSubKey("Acrobat Reader");
- if (acroRead != null)
- {
- try
- {
- string[] acroReadVersions = acroRead.GetSubKeyNames();
- sKey = adobe.OpenSubKey("Acrobat Reader").OpenSubKey(acroReadVersions[0]).OpenSubKey("InstallPath").ToString();
- pPath = Convert.ToString(Registry.GetValue(sKey, "", ""));
- bInstalled = !string.IsNullOrEmpty(pPath);
- }
- catch (Exception exc)
- {
- }
- }
- else
- {
- acroRead = adobe.OpenSubKey("Adobe Acrobat"); // acrobat dc reader 2022
- if (acroRead != null)
- {
- try
- {
- string[] acroReadVersions = acroRead.GetSubKeyNames();
- sKey = adobe.OpenSubKey("Adobe Acrobat").OpenSubKey(acroReadVersions[0]).OpenSubKey("InstallPath").ToString();
- pPath = Convert.ToString(Registry.GetValue(sKey, "", ""));
- bInstalled = !string.IsNullOrEmpty(pPath);
- }
- catch (Exception exc)
- {
- }
- }
- }
- }
- return bInstalled;
- }
Advertisement
Add Comment
Please, Sign In to add comment