开发者

C# Interacting with existing executables in Windows CE using Compact Framework?

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 C开发者_如何学Pythonompact Framework.

Thanks in advance!


"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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜