2010-01-14 111 views

回答

0

我落得這樣做:

Process[] apps=Process.GetProcesses(); 
foreach (Process p in apps) 
{ 
    if (p.MainWindowHandle.ToInt32()>0) 
    { 
     NativeWin32.SetForegroundWindow(p.MainWindowHandle.ToInt32()); 

     //send control shift 2 to switch the language bar back to english. 
     System.Windows.Forms.SendKeys.SendWait("^+(2)"); 

     p.Dispose(); 
    } 
} 
0

自從Windows XP在童年時代以來,我還沒有這樣做過,所以您可能想要檢查語言支持是否仍然基於相同的原則。它都是Win32,因此需要爲C#導入它們。

首先,在MSDN上關於鍵盤輸入的頁面閱讀: http://msdn.microsoft.com/en-us/library/ms645530%28VS.85%29.aspx

GetKeyboardLayoutList告訴你什麼佈局安裝 LoadKeyboardLayout加載新的輸入法區域設置IDENTIFER。 ActivateKeyboardLayout設置當前語言

0

一個更好的這種做法是這樣的:

//change input language to English 
InputLanguage currentLang = InputLanguage.CurrentInputLanguage; 
InputLanguage newLang = InputLanguage.FromCulture(System.Globalization.CultureInfo.GetCultureInfo("en-US")); 
if (newLang == null) 
{ 
    MessageBox.Show("The Upload Project function requires the En-US keyboard installed.", "Missing keyboard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
    return; 
} 
else 
{ 
    InputLanguage.CurrentInputLanguage = newLang; 
} 

見本完整的文章:Language Bar change language in c# .NET