std::system() 无法正常工作
std::system() not working correctly
如果我在命令行上执行命令 "C:\Windows\system32\java.exe",我将获得有关如何按应有的方式使用 java 的信息。然而,当我编写一个简单的 C++ 程序来做同样的事情时
#include <iostream>
int main()
{
std::system("C:\Windows\system32\java.exe");
return 0;
}
我得到以下控制台输出:
'C:\Windows\system32\java.exe' is not recognized as an internal or external command,
operable program or batch file.
我在 windows 10.
上使用 mingw-w64 编译器
这是 Windows 在 x64 系统上的兼容性 redirection:
In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64.
如果您的控制台是 64 位的,而应用程序构建为 32 位的(反之亦然),它们将以相同的名称显示不同 system32 目录的内容。
如果我在命令行上执行命令 "C:\Windows\system32\java.exe",我将获得有关如何按应有的方式使用 java 的信息。然而,当我编写一个简单的 C++ 程序来做同样的事情时
#include <iostream>
int main()
{
std::system("C:\Windows\system32\java.exe");
return 0;
}
我得到以下控制台输出:
'C:\Windows\system32\java.exe' is not recognized as an internal or external command,
operable program or batch file.
我在 windows 10.
上使用 mingw-w64 编译器这是 Windows 在 x64 系统上的兼容性 redirection:
In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64.
如果您的控制台是 64 位的,而应用程序构建为 32 位的(反之亦然),它们将以相同的名称显示不同 system32 目录的内容。