我正在尝试从 C++ 程序运行可执行文件。我查看并找到了 2 个选项:
系统("C:\文件路径\文件.exe");
和
ShellExecute(GetDesktopWindow(), "open", "C:\filepath\file.exe", NULL, NULL, SW_SHOWNORMAL);
万物皆美,唯独行不通。
对于第一个选项,除了 windows.h 之外,我还必须包含 cstdlib,否则我的代码无法构建。
当我运行程序时,出现错误:
“file.exe”不是内部或外部命令
我已经为我的项目设置了公共(public)语言运行时支持 (/clr) 选项(我还必须为运行时库设置多线程调试 DLL (/MDd) 选项,否则它不会构建)。< br/>
即使包含两个库,第二个选项也不会构建。我得到错误:
错误 C3861:“ShellExecute”:找不到标识符
我在 Windows7 上使用 VS2010 - 并希望它能在多平台上工作...
我是不是要求太多了?
谢谢。
最佳答案
When I run the program, I get the error: "file.exe" is not recognized as an internal or external command
如果我启动命令行提示符并输入 file.exe,这就是我得到的:
Microsoft Windows [Version 6.1.7100]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\>file.exe
'file.exe' is not recognized as an internal or external command,
operable program or batch file.
C:\>
关于C++ 执行外部进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9439361/