现在的位置: 首页 > 综合 > 正文

C#:获取系统环境语言

2013年09月10日 ⁄ 综合 ⁄ 共 649字 ⁄ 字号 评论关闭
using System;
using System.Runtime.InteropServices;

namespace Splash
{
    public class Environment
    {
        [DllImport("kernel32.dll")]
        private static extern UInt16 GetUserDefaultUILanguage();

        [DllImport("kernel32.dll")]
        private static extern UInt16 GetSystemDefaultLangID();

        [DllImport("kernel32.dll")]
        private static extern UInt16 GetUserDefaultLangID();

        /// <summary>
        /// 用户缺省界面语言
        /// </summary>
        public static UInt16 UserDefaultUILanguage
        {
            get
            {
                return GetUserDefaultUILanguage();
            }
        }

        /// <summary>
        /// 用户缺省语言
        /// </summary>
        public static UInt16 UserDefaultLangID
        {
            get
            {
                return GetUserDefaultLangID();
            }
        }

        /// <summary>
        /// 系统缺省语言
        /// </summary>
        public static UInt16 SystemDefaultLangID
        {
            get
            {
                return GetSystemDefaultLangID();
            }
        }        
    }
}

抱歉!评论已关闭.