C++ 执行外部进程

标签 c++ process

我正在尝试从 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/

相关文章:

c++ - 使用调试文件构建 C++ 项目

C++:检查存储在 std::any 中的值是否是整数

linux - 取证分析 - 过程日志

字典列表上的 Python 多处理

java - 跨 Java 进程共享对象

C++ 未定义对 `_imp__glewInit@0` 的引用

c++ - std::vector 操作在某些系统上速度较慢

c# - 当 64 位非托管代码通过 COM 调用托管代码时会发生什么

c - 如何防止子进程中的 SIGINT 传播到父进程并杀死父进程?

bash - 使用 while 或 until 等到 PID 不存在