/// <summary>
        /// 獲取輸入法名稱
        /// </summary>
        /// <param name="profile">輸入法</param>
        public string GetLanguageProfileDescription(LanguageProfile profile)
        {
            Result result = inputProcessorProfiles.GetLanguageProfileDescription(profile.clsid, profile.langid, profile.guidProfile, out string desc);

            result.CheckError();
            return(desc);
        }
        /// <summary>
        /// 切換至輸入法 (需啟用)
        /// </summary>
        /// <param name="profile">輸入法</param>
        public void ActivateLanguageProfile(LanguageProfile profile)
        {
            inputProcessorProfiles.GetCurrentLanguage(out var current_langid);
            Result result = 0;

            if (current_langid != profile.langid)
            {
                // 先切換語言才能切換輸入法
                result = inputProcessorProfiles.ChangeCurrentLanguage(profile.langid);
                result.CheckError();
            }
            result = inputProcessorProfiles.ActivateLanguageProfile(profile.clsid, profile.langid, profile.guidProfile);
            result.CheckError();
        }
        /// <summary>
        /// 獲取該語言的輸入法
        /// </summary>
        /// <param name="langid">語言</param>
        public LanguageProfile[] GetLanguageProfiles(LANGID langid)
        {
            List <LanguageProfile> list = new List <LanguageProfile>();

            Result result = inputProcessorProfiles.EnumLanguageProfiles(langid, out IEnumTfLanguageProfiles enumerator);

            if (!result.OK)
            {
                return(list.ToArray());
            }

            IntPtr p = Marshal.AllocCoTaskMem(Marshal.SizeOf <LanguageProfile>());

            while ((result = enumerator.Next(1, p, out var fetched)).HResult == 0)
            {
                LanguageProfile profile = new LanguageProfile();
                Marshal.PtrToStructure(p, profile);
                list.Add(profile);
            }
            Marshal.FreeCoTaskMem(p);

            return(list.ToArray());
        }
        /// <summary>
        /// 設定預設輸入法
        /// </summary>
        public void SetDefaultLanguageProfile(LanguageProfile profile)
        {
            Result result = inputProcessorProfiles.SetDefaultLanguageProfile(profile.langid, profile.clsid, profile.guidProfile);

            result.CheckError();
        }
 /// <summary>
 /// 詢問該輸入法是否啟用
 /// </summary>
 /// <param name="profile">輸入法</param>
 public bool IsEnabledLanguageProfile(LanguageProfile profile)
 {
     inputProcessorProfiles.IsEnabledLanguageProfile(profile.clsid, profile.langid, profile.guidProfile, out bool enable);
     return(enable);
 }