本文介绍了启动explorer.exe在C#中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#创建一个简单的应用程序,该应用程序使我可以终止并启用explorer.exe.我需要这样的程序,以便我可以正常玩《帝国时代2》,因为出于某些原因它不喜欢explorer.exe(我相信它与Aero有关).因此,我做了两个按钮,一个启用了explorer.exe,另一个则禁用了它.杀死explorer.exe没问题,但是启用却没有.

I'm trying to make a simple application in C# that allows me to kill and enable explorer.exe. I need such program so that I can play Age of Empires 2 properly, because it does not like explorer.exe for some reason (I believe it has to do with Aero). So I made two buttons, one that enables explorer.exe and the other one disables it. Killing explorer.exe went ok, but enabling didn't.

我在一些站点上读到,您必须使用 Process.Start(); 来启动进程.所以我做了 Process.Start("explorer.exe"); .杀死explorer.exe后,它执行了上一行,但是并没有退回我的任务栏,而是仅打开了库"而没有退还我的任务栏.我还尝试了 Process.Start("explorer.exe","-p"); (我在某处看到它),但是打开了我的文档".

I read on a few sites that you have to use the Process.Start(); to start a process. So I made Process.Start("explorer.exe");. After killing explorer.exe, it executed the previous line but instead of having my taskbar back, it opened 'Libraries' only without giving my taskbar back. I also tried Process.Start("explorer.exe", "-p"); (I saw it somewhere), but that opened 'My Documents'.

我该怎么办,这将启动进程explorer.exe,这样我就可以回到任务栏之类的东西了?我仍然可以使用命令提示符/任务管理器/运行来正确启动它.

What can I do so it starts the process explorer.exe so that I have the things like the taskbar back? I can still launch it properly with Command Prompt/Task Manager/Run.

推荐答案

那个主题:

foreach(Process p in Process.GetProcesses())
{
    try
    {
        // Compare it with "explorer".
        if(p.MainModule.ModuleName.Contains("explorer") == true)
        {
            p.Kill();
        }
    }
    catch(Exception e)
    {
        // Do some exception handling here.
    }

    // Restart explorer.
    Process.Start("explorer.exe");
}

给个机会.

这篇关于启动explorer.exe在C#中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:12