[DllImport("imm32.dll")]
public static extern IntPtr ImmGetContext(IntPtr hWnd);
[DllImport("imm32.dll")]
public static extern bool ImmGetConversionStatus(IntPtr hIMC,
ref int conversion, ref int sentence);
[DllImport("imm32.dll")]
public static extern bool ImmSetConversionStatus(IntPtr hIMC, int conversion, int sentence);
foreach (InputLanguage iL in InputLanguage.InstalledInputLanguages)
{
if (iL.LayoutName == "中文(简体)-搜狗拼音输入法")
{
InputLanguage.CurrentInputLanguage = iL;
break;
}
}
IntPtr prt = ImmGetContext(this.Handle);
int iMode = 1033;
int iSentence = 0;
if (!ImmSetConversionStatus(prt, iMode, iSentence))
{
MessageBox.Show("change error");
}