程式以 32 位元模式編譯(Cocos2d-x 專案限制),呼叫 system("snippingtool") 或 system("osk") 等系統工具失敗,提示「不是內部或外部命令」。64 位元模式下正常。
C:\Windows\SysWOW64,該目錄不包含部分僅有 64 位元版本的系統工具(如 snippingtool.exe, osk.exe)。C:\Windows\System32,工具完整存在。system("C:\\Windows\\Sysnative\\snippingtool.exe");
Sysnative 是 WoW64 提供的虛擬目錄,32 位元進程訪問時會自動重導向至真正的 64 位元 System32。
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.lpVerb = "open";
sei.lpFile = "snippingtool.exe";
sei.nShow = SW_SHOW;
ShellExecuteEx(&sei);
Shell API 會自動處理架構匹配。
Cocos2d-x 3.17+ 已支援 64 位元,升級專案設定可從根本解決。
在命令提示字元執行 where snippingtool,確認 64 位元路徑存在;32 位元 cmd 執行 dir C:\Windows\Sysnative\snippingtool.exe 驗證重導向生效。