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

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

我工作的一个Windows外壳扩展,不幸的是,在更改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).

我发现这个节目从恐龙埃斯波西托,但它不为我工作。

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。我意识到,我可以去任务管理器,杀死Explorer进程,但我只是想做到这一点偷懒的方法。此外,这使得自​​动化。

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.

PPS我使用.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.

推荐答案

一个很简单的解决方案:

A fool-proof solution:

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

发布评论

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

>www.elefans.com

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