我如何正确地关闭从C#WinForm的屏幕上的键盘的过程? [英] How do I close the on-screen keyboard process from C# winform correctly?
问题描述
我目前正在设计一个图像浏览器,允许用户输入她的电子邮件和数字得到的图像。这困扰我的部分是让屏幕上的键盘关闭。我使用这段代码,启动Windows进程:
字符串progFiles = @C:\Program Files\Common Files\Microsoft Shared\ink;
串keyboardPath = Path.Combine(progFilesTabTip.exe);
过程keyboardProc =的Process.Start(keyboardPath);
在这之后我打开一个VB输入框,为电子邮件地址提示(我用的屏幕上的键盘,因为应用程序将显示在触摸屏上)。后此提示我要自动关闭过程
我试着用下面的关闭过程:
keyboardProc.Kill();
keyboardProc.Dispose();
keyboardProc.Close();
keyboardProc = NULL;
他们没有工作,只是抛出异常:
'System.InvalidOperationException'类型的未处理的异常出现在System.dll中
附加信息:因为进程已退出无法处理请求。
我也试图通过ID识别过程,并关闭它这样,也不能工作。
我也看了一下:
的 C#/。NET:关闭外面主窗口
另一个进程,但没有得到它要么工作..:(
我敢新的C#,这是我第一次从代码中调用Windows进程? - 我失去的东西。
非常感谢你提前! p>
U可以这样做:
工艺过程=新工艺();
process.StartInfo.FileName = progFiles; //文件名
的Process.Start();
process.Close();
I'm currently designing an image viewer that allows the user to input her e-mail and get the images digitally. The part that troubles me is getting the on-screen keyboard to close. I use this piece of code to start the windows process:
string progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
string keyboardPath = Path.Combine(progFiles, "TabTip.exe");
Process keyboardProc = Process.Start(keyboardPath);
After which i open a VB InputBox to prompt for the e-mail address (for which i use the on-screen keyboard, since the application will be shown on a touch screen). After this prompt I want to close the process automatically.
I've tried to close the process with the following:
keyboardProc.Kill();
keyboardProc.Dispose();
keyboardProc.Close();
keyboardProc = null;
None of them works and simply throws the exception:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll
Additional information: Cannot process request because the process has exited.
I also tried identifying the process by ID and closing it this way, didn't work either. I also had a look at: C#/.NET: Closing another process outside the main window but didn't get it working either.. :(
I'm pretty new to C# and this is the first time I've invoked a windows process from code - am I missing something?
Thank you very much in advance!
u can do:
Process process = new Process();
process.StartInfo.FileName = progFiles;//Filename
process.Start();
process.Close();
这篇关于我如何正确地关闭从C#WinForm的屏幕上的键盘的过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!