如何以编程方式重新启动 Windows 资源管理器进程

编程入门 行业动态 更新时间:2024-10-28 02:32:52
本文介绍了如何以编程方式重新启动 Windows 资源管理器进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发 Windows Shell 扩展,不幸的是,在更改 DLL 时,我必须重新启动 Windows 资源管理器(因为它将 DLL 保留在内存中).

I'm working on a windows shell extension, and unfortunately, when making changes to the DLL, I must restart windows explorer (since it keeps the DLL in memory).

我从 Dino Esposito 找到了这个程序,但它对我不起作用.

I found this program from Dino Esposito, but it doesn't work for me.

void SHShellRestart(void) { HWND hwnd; hwnd = FindWindow("Progman", NULL ); PostMessage(hwnd, WM_QUIT, 0, 0 ); ShellExecute(NULL, NULL, "explorer.exe", NULL, NULL, SW_SHOW ); return; }

有没有人可以分享一些东西来做到这一点?

Does any one have something they can share to do this?

附言我意识到我可以去任务管理器并杀死资源管理器进程,但我只想以懒惰的方式来做.此外,这可以实现自动化.

P.S. I realize that I can go to task manager and kill the explorer process, but I just want to do it the lazy way. Besides, this enables automation.

P.P.S 我使用 .NET 进行开发,但外壳重启功能可以是 C、C++ 或 .NET 语言.它只是一个小的独立可执行文件.

P.P.S I am using .NET for the development, but the shell restart functionality could be in C, C++ or a .NET language. It will simply be a small stand-alone executable.

推荐答案

万无一失的解决方案:

foreach (Process p in Process.GetProcesses()) { // In case we get Access Denied try { if (p.MainModule.FileName.ToLower().EndsWith(":\windows\explorer.exe")) { p.Kill(); break; } } catch { } } Process.Start("explorer.exe");

更多推荐

如何以编程方式重新启动 Windows 资源管理器进程

本文发布于:2023-11-03 19:51:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555935.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   资源管理器   进程   方式   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!