【发布时间】:2012-01-11 15:55:04
【问题描述】:
我有一个需要重新启动 Explorer 的替换 shell。 目前我正在使用:
CreateProcess(nil, zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS, nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) { pointer to PROCESS_INF }
这在 Windows XP/Vista 等中运行良好,但在 Windows 7 上不是重新启动资源管理器,它只是打开一个资源管理器窗口。
In answer to a related question for .Net,Robolt 写道:
我注意到没有人解决将 explorer.exe 作为 shell 启动的问题,而不仅仅是打开资源管理器窗口。我花了一段时间才弄明白,原来这很简单”:
string explorer = string.Format("{0}\\{1}", Environment.GetEnvironmentVariable("WINDIR"), "explorer.exe"); Process process = new Process(); process.StartInfo.FileName = explorer; process.StartInfo.UseShellExecute = true; process.Start();您必须将 StartInfo.UseshellExecute 设置为 true 才能让它作为 shell 重新启动。
但我不知道如何在 Delphi 中执行此操作。有没有人遇到过这个问题的解决方案?
【问题讨论】:
-
我认为它是第一个启动 shell 的资源管理器实例。也许在您的 XP/Vista 测试中“在单独的进程中启动文件夹窗口”没有被选中,而在“7”中它是,所以你实际上并没有杀死所有的“explorer.exe”。
-
我正在使用 ctrl shift 右键单击开始按钮以确保在测试期间没有资源管理器在运行。对于部署,这不是必需的,因为它正在替换 shell。
标签: delphi delphi-xe windows-shell