我使用的是 Win 7 64b。 我正在尝试从我的 delphi 应用程序运行 msconfig。 msconfig.exe 文件位于 system32 文件夹中。 我将 msconfig.exe 复制到 c:\,效果很好。 这看起来像是某种权限问题。
var
errorcode: integer;
begin
errorcode :=
ShellExecute(0, 'open', pchar('C:\Windows\System\msconfig.exe'), nil, nil, SW_NORMAL);
if errorcode <= 32 then
ShowMessage(SysErrorMessage(errorcode));
end;
有人见过这个并弄清楚如何从 sys32 运行 msconfig.exe 吗?
最佳答案
此行为是由 File System Redirector
引起的作为解决方法,您可以使用 Wow64DisableWow64FsRedirection
和 Wow64EnableWow64FsRedirection
功能。
{$APPTYPE CONSOLE}
uses
ShellAPi,
SysUtils;
Function Wow64DisableWow64FsRedirection(Var Wow64FsEnableRedirection: LongBool): LongBool; StdCall;
External 'Kernel32.dll' Name 'Wow64DisableWow64FsRedirection';
Function Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection: LongBool): LongBool; StdCall;
External 'Kernel32.dll' Name 'Wow64EnableWow64FsRedirection';
Var
Wow64FsEnableRedirection: LongBool;
begin
try
Wow64DisableWow64FsRedirection(Wow64FsEnableRedirection);
ShellExecute(0, nil, PChar('C:\Windows\System32\msconfig.exe'), nil, nil, 0);
Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
关于delphi - 无法让 msconfig.exe 在 system32 文件夹中运行 shellexecute Delphi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12849939/