コード例 #1
0
ファイル: Helpers.cs プロジェクト: TFB12332/ShareX1
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: Helpers.cs プロジェクト: TFB12332/ShareX1
        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);
        }