You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Delphi 10.4程序无法访问/执行c:\windows\system32\rdpclip.exe求助

问题原因与解决方案

核心原因

你的Delphi程序是32位编译的,在64位Windows 10系统中,32位程序访问C:\Windows\System32会被系统自动重定向到C:\Windows\SysWOW64(存放32位系统文件的目录)。而rdpclip.exe是64位专属程序,仅存在于C:\Windows\System32中,SysWOW64里没有对应的32位版本,所以32位程序会找不到它。

而cmd.exe同时存在64位(System32)和32位(SysWOW64)版本,32位程序访问时会被重定向到SysWOW64的32位cmd.exe,因此能正常找到。


解决办法

1. 临时禁用WOW64文件重定向

通过Windows API在需要访问System32的代码段临时禁用重定向,操作完成后恢复:

uses
  Windows;

procedure CheckAndRunRdpClip;
var
  OldRedirectionState: PByte;
begin
  // 禁用文件系统重定向
  if Wow64DisableWow64FsRedirection(@OldRedirectionState) then
  try
    // 此时访问System32会直接指向64位目录
    if FileExists('C:\Windows\System32\rdpclip.exe') then
    begin
      ShellExecute(0, 'open', 'C:\Windows\System32\rdpclip.exe', nil, nil, SW_SHOWNORMAL);
    end;
  finally
    // 必须恢复重定向,避免影响其他逻辑
    Wow64RevertWow64FsRedirection(OldRedirectionState);
  end;
end;

2. 使用Sysnative虚拟路径访问

对于32位程序,Windows提供了C:\Windows\Sysnative虚拟路径,它会直接映射到真正的64位System32目录:

// 直接用Sysnative路径访问
if FileExists('C:\Windows\Sysnative\rdpclip.exe') then
  ShellExecute(0, 'open', 'C:\Windows\Sysnative\rdpclip.exe', nil, nil, SW_SHOWNORMAL);

3. 编译为64位程序

如果你的Delphi项目支持64位目标平台,直接将项目编译为64位程序。64位程序访问C:\Windows\System32不会触发重定向,能直接找到rdpclip.exe,无需额外处理。


内容的提问来源于stack exchange,提问作者Vlad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 12:47:04