首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >system.componentmodel.win32exception ={“系统无法找到指定的文件”}在窗口7中从c#打开叙述器时出现}错误

system.componentmodel.win32exception ={“系统无法找到指定的文件”}在窗口7中从c#打开叙述器时出现}错误
EN

Stack Overflow用户
提问于 2015-09-03 11:12:05
回答 1查看 706关注 0票数 0

我正试图使用c#和它在窗口7中打开“叙事者”屏幕阅读器。

引发system.componentmodel.win32exception ={“系统找不到指定的文件”}异常。

此外,我还编写了一个程序来列出system32 dir中的所有system32文件,它没有显示叙述者。为什么会发生这种情况,以及如何使用c#自动打开叙述器。

//试图打开开始讲述者抛出异常

代码语言:javascript
复制
ProcessStartInfo narratorProcessInfo = new ProcessStartInfo();            
try
{
    Console.WriteLine("Starting Narrator");
    Console.WriteLine("Opening time: " + DateTime.Now);

    narratorProcessInfo.FileName = "C:\\Windows\\system32\\Narrator.exe";

    using (Process narratorProcess = Process.Start(narratorProcessInfo))
    {
        narratorProcess.StartInfo.UseShellExecute = true;
        Console.WriteLine("Waiting for 5 seconds");
        Thread.Sleep(2000);
        narratorProcess.Kill();
    }
}
catch (Exception ex)
{
    Console.WriteLine("The exception message: "+ ex);
}
Console.WriteLine("Press any key to exit");
Console.ReadLine();

//列出system32目录中的所有文件,但不显示旁白

代码语言:javascript
复制
Process pp = new Process();            
try
{
    string[] files = Directory.GetFiles(@"C:\Windows\System32"); // <-- Case-insensitive
    // Display all BIN files.
    Console.WriteLine("--- exe Files: ---");
    foreach (string name in files)
    {
        Console.WriteLine(name);
        Thread.Sleep(1000);
        if (name.Contains("Narrator"))
        {
             pp.StartInfo.FileName = name;
             pp.Start();
             Console.WriteLine("Waiting  5 sec");
             Thread.Sleep(5000);
             break;
        }
   }
}
catch (Exception ex)
{
     Console.WriteLine("The exception message: " + ex);
}            
Console.WriteLine("Press any key to exit");
Console.ReadLine();
EN

回答 1

Stack Overflow用户

发布于 2015-09-03 11:28:50

据我所知,当您试图在System32中直接访问C#进程时,后台会发生重定向。您需要关闭魔兽世界重定向,以阻止您启动系统进程。

试试这个链接,看看它是否对你有帮助:C#中的WOW重定向失活

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32374030

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档