C++ ShellExecute 的工作方式与 cmd.exe 不同
C++ ShellExecute is not working the same way as cmd.exe
我运行这个命令
w_icrcom.exe j11 hola
在命令提示符下运行正常,exe 是 运行 使用参数。
但是当我从 C++ 程序中执行相同操作时,w_icrcom.exe
的行为有所不同。我收到一条错误消息 "abnormal program termination"。虽然只有当您将参数传递给 'w_icrcom.exe'.
时才会发生这种情况
在我看来,当我执行命令时一切正常,但是当其他程序试图执行相同的命令时它不起作用并且我收到 "abnormal program execution" 错误。
我在 ShellExecute
上尝试了相同的设置,调用 notepad.exe
并传递参数,它运行良好。这个问题有什么合乎逻辑的解释吗?
string test_var = ("j11 hola");
ShellExecute(0, "open", "C:\Users\PC\Desktop\My First\connect\bin\w_icrcom.exe", test_var.c_str(), 0, SW_SHOW);
ShellExecute
的倒数第二个参数是 'working directory'。它可能需要设置为正在运行的 cmd 提示符中的当前目录。
我运行这个命令
w_icrcom.exe j11 hola
在命令提示符下运行正常,exe 是 运行 使用参数。
但是当我从 C++ 程序中执行相同操作时,w_icrcom.exe
的行为有所不同。我收到一条错误消息 "abnormal program termination"。虽然只有当您将参数传递给 'w_icrcom.exe'.
在我看来,当我执行命令时一切正常,但是当其他程序试图执行相同的命令时它不起作用并且我收到 "abnormal program execution" 错误。
我在 ShellExecute
上尝试了相同的设置,调用 notepad.exe
并传递参数,它运行良好。这个问题有什么合乎逻辑的解释吗?
string test_var = ("j11 hola");
ShellExecute(0, "open", "C:\Users\PC\Desktop\My First\connect\bin\w_icrcom.exe", test_var.c_str(), 0, SW_SHOW);
ShellExecute
的倒数第二个参数是 'working directory'。它可能需要设置为正在运行的 cmd 提示符中的当前目录。