public static string GetOperatingSystemProductName(bool includeBit = false) { string productName = null; try { productName = RegistryHelpers.GetRegistryValue(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", RegistryHive.LocalMachine); } catch { } if (string.IsNullOrEmpty(productName)) { productName = Environment.OSVersion.VersionString; } if (includeBit) { string bit; if (Environment.Is64BitOperatingSystem) { bit = "64"; } else { bit = "32"; } productName = $"{productName} ({bit}-bit)"; } return(productName); }
public static string GetMimeType(string fileName) { if (!string.IsNullOrEmpty(fileName)) { string ext = Path.GetExtension(fileName).ToLowerInvariant(); if (!string.IsNullOrEmpty(ext)) { string mimeType = MimeTypes.GetMimeType(ext); if (!string.IsNullOrEmpty(mimeType)) { return(mimeType); } mimeType = RegistryHelpers.GetRegistryValue(ext, "Content Type", RegistryHive.ClassesRoot); if (!string.IsNullOrEmpty(mimeType)) { return(mimeType); } } } return(MimeTypes.DefaultMimeType); }
public static Size GetCursorBaseSize() { try { int cursorBaseSize = RegistryHelpers.GetValueDWord(@"Control Panel\Cursors", "CursorBaseSize"); return(new Size(cursorBaseSize, cursorBaseSize)); } catch { return(Size.Empty); } }
public static string GetWindowsProductName() { try { string productName = RegistryHelpers.GetRegistryValue(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", RegistryHive.LocalMachine); if (!string.IsNullOrEmpty(productName)) { return(productName); } } catch { } return(Environment.OSVersion.VersionString); }
public static float GetCursorSizeMultiplier() { float sizeMultiplier = 1f; try { int cursorSize = RegistryHelpers.GetValueDWord(@"SOFTWARE\Microsoft\Accessibility", "CursorSize"); if (cursorSize > 1) { sizeMultiplier = 1f + ((cursorSize - 1) * 0.5f); } } catch { } return(sizeMultiplier); }