gpt4 book ai didi

delphi - 无法让 msconfig.exe 在 system32 文件夹中运行 shellexecute Delphi

转载 作者:行者123 更新时间:2023-12-03 15:41:09 26 4
gpt4 key购买 nike

我使用的是 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 引起的作为解决方法,您可以使用 Wow64DisableWow64FsRedirectionWow64EnableWow64FsRedirection功能。

{$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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com