C# 使用 Compact Framework 与 Windows CE 中的现有可执行文件交互?
我将如何使用 Compact Framework 与 Windows CE 上的现有可执行文件进行交互?
我想我忽略了一些简单的事情。
场景如下:
我正在尝试编写一个小应用程序来执行一些常见功能,例如使用指定密码创建用户。
windows 目录有一些我想使用的可执行文件。我遇到的问题是“passwd.exe”,
仅通过传递参数无法使用该可执行文件。它提示输入。
使用示例:
input> passwd.exe MyUser
output> Current Password: [wait for input]
output> New Password: [wait for input]
output> Retype Password: [wait for input]
所以我在非移动框架中看到了 System.Diagnostics.ProcessStartInfo 的一些类似用途,但这似乎不是紧凑框架的一个选项。
提前致谢!
How would I go about interacting with an existing executable on Windows CE using the Compact Framework?
I figure I am overlooking something simple.
Here is the scenario:
I am trying to write a small app to do some common functions such as creating a user with a specified password.
The windows directory has a few executeables which I would like to use. The one I am having trouble with is "passwd.exe"
This executable is not able to be used by just passing it args. It prompts for input.
Example of use:
input> passwd.exe MyUser
output> Current Password: [wait for input]
output> New Password: [wait for input]
output> Retype Password: [wait for input]
So I have seen some similar uses of System.Diagnostics.ProcessStartInfo in non-mobile framework but this doesn't seem to be an option the Compact Framework.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与现有可执行文件“交互”将在很大程度上取决于可执行文件。
首先,我要郑重声明,我非常倾向于询问设备 OEM 是否有办法以编程方式完成所有这些工作,而不是试图将一些模拟用户输入拼凑在一起。在这种情况下,该应用程序可能会在系统中的某个位置设置该信息,因此,如果您可以执行相同的操作并完全避免使用他们的应用程序,那么它会变得更加干净。
如果这不可用,那么如果您想要与之交互的应用程序支持命令行选项,那么这将是最简单的。您可以使用 Process 和 ProcessStartInfo 类来发送命令行参数。
如果没有,那么您必须模拟实际的用户输入。同样,它的工作原理取决于您尝试与之交互的应用程序。根据您的描述,您很可能必须通过 P/Invoking PostKeyboardMessage 或 keydb_event 来模拟键盘敲击(SDF 有一个 SendKeys 实现可以简化此操作)。
请注意,在发送这些击键之前,您必须确保输入的目标窗口已聚焦。
"interacting" with an existing executable is going to greatly depend on the executable.
First, let me go on record as saying I'd be highly inclined to ask the device OEM if they have a way to do all of this programmatically rather than trying to kludge together some simulated user input. In this case, the app is likely setting that info somewhere in the system, so if you can do the same and avoid their app altogetehr, it's going to be a lot cleaner.
If that isn't available, then if the app you want to interact with support command-line options, then that's going to be the easiest. You can send those in using the Process and ProcessStartInfo classes to send in command-line arguments.
If it doesn't, then you have to simulate actual user input. How that would work, again, depens on the app you're trying to interact with. From your description, you're most likely you're going to have to simulate keyboard strokes by P/Invoking PostKeyboardMessage or keydb_event (the SDF has an implementation of SendKeys that simplifies this).
Be aware that you're going to have to make sure that the target window for the input is focused before you send those key strokes.