寻C#高手,系统API高手

来源:百度知道 编辑:UC知道 时间:2024/06/22 21:54:22
问题一:在C#中用什么代码可以调用DOS命令?
问题二:user32.dll中的ExitWindownEx()方法接收什么样在参数。怎么样才能调用程序实现关机,注销和重启呢。
问题三:我试过ExitWindownEx(0,0)在win2000上执行为什么老是注销,没有关机。为什么?
问题四:怎么样调用系统API中的音频处理实现点名程序(我想输入一个名字然后操作系统能把这几个字读出来?怎么实现)
第一题:然后重定向一下命令行输入输出就可以了?这个不太明白?如果那样调用只能将CMD窗口打开。不能将命令写在代码中。程序调用吧?
后两题:那些参数我找到过。但是好像看不懂。可能是汇编语言吧。直接说一下。我在2000或其它系统上如果调用这个命令实现关机、重启、注消,分别要跟哪些参数呢。
AdjustTokenPrivileges怎么取得权限?得到了权限之后怎么调用关机方法
能说详细点吗?(下面的参数最好有中文注解)谢谢!~

您好,

第一个问题,使用System.Diagnostics命名空间中的Process类可以实现。

Process p = new Process();
p.Start("cmd.exe");

然后重定向一下命令行输入输出就可以了。

第二个问题,ExitWindowsEx可以关机和重启。参数见下。

第三个问题,ExitWindowsEx(0,0)的作用就是注销,见ExitWindowsEx参数。

第四个问题,可以调用Speech API完成此功能,不过代码量比较大,而且在XP中默认只能说英文。

ExitWindowsEx函数MSDN说明:

BOOL ExitWindowsEx(
UINT uFlags,
DWORD dwReason
);

uFlags
[in] Shutdown type. This parameter must include one of the following values. Value Meaning
EWX_LOGOFF
0 Shuts down all processes running in the logon session of the process that called the ExitWindowsEx function. Then it logs the user off.
This flag can be used only by processes running in an interactive user's logon session.

EWX_POWEROFF
0x00000008 Shuts down the system and turns off the power. The system must support the power-off feature.
The calling process must have the SE_S