win10下,通过TSF设置指定输入法

https://blog.csdn.net/weixin_33890499/article/details/86017625
你好,我通过你上述的方法,得到了系统中的所有输入法,那我现在想要指定某一个输入法,但是好像没有效果.
下面是我使用的方法,我的系统是win10,有搜狗和微软拼音,想要在搜狗输入法的状态下,设置为微软拼音

SetCurrentLangInputMethod(0x804, "微软拼音");
 public static void SetCurrentLangInputMethod(short langID,string inputMethod)
    {
        ITfInputProcessorProfiles profiles;
        if (TSF_NativeAPI.TF_CreateInputProcessorProfiles(out profiles) == 0)
        {
            try
            {
                IEnumTfLanguageProfiles enumerator = null; 
                if (profiles.EnumLanguageProfiles(langID, out enumerator) == 0)
                {
                    if (enumerator != null)
                    {
                        TF_LANGUAGEPROFILE[] langProfile = new TF_LANGUAGEPROFILE[1];
                        int fetchCount = 0;
                        while (enumerator.Next(1, langProfile, out fetchCount) == 0)
                        {
                            IntPtr ptr;
                            if (profiles.GetLanguageProfileDescription(ref langProfile[0].clsid, langProfile[0].langid, ref langProfile[0].guidProfile, out ptr) == 0)
                            {
                                bool enabled;
                                if (profiles.IsEnabledLanguageProfile(ref langProfile[0].clsid, langProfile[0].langid, ref langProfile[0].guidProfile, out enabled) == 0)
                                {
                                    if (enabled)
                                    {
                                        if (Marshal.PtrToStringBSTR(ptr)== inputMethod)
                                        {
                                            int result = profiles.ActivateLanguageProfile(ref langProfile[0].clsid,langProfile[0].langid, ref langProfile[0].guidProfile);
                                        }
                                    }
                                }
                            }
                            Marshal.FreeBSTR(ptr);
                        }
                    }
                }
            }
            finally
            {
                Marshal.ReleaseComObject(profiles);
            }
        }
    }