我有以下代码,当用户单击按钮时,它会打开键盘属性对话框:
Process proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.FileName = "main.cpl";
proc.StartInfo.Arguments = "keyboard";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
proc.Start();
proc.WaitForExit();
int keyBoardWindow;
while ((keyBoardWindow = FindWindow(null, "Keyboard Properties")) == 0) ;
int isSet = SetForegroundWindow(keyBoardWindow);
当您的系统的默认语言是英语时,此代码可以正常工作,如果是中文等其他语言,则该FindWindow
方法不会退出。可能是因为对话框窗口不再具有名称“键盘属性”。你们有什么建议?我应该如何处理这个问题,以便我能够打开键盘属性对话框,无论系统的语言是什么。