ShellExecute和CMD命令之间有什么区别,如果有的话
What is the difference between ShellExecute and CMD commands, if any?
执行方面,这两个命令之间有什么区别,除了一个用于C++,另一个是CMD的事实?
因为我遇到了一个奇怪的问题,所以我有一个.exe,它需要争论。当我用CMD的参数调用这个exe时,它工作正常。但是当我从 ShellExecute 做同样的事情时,程序会返回错误。
可能出了什么问题?
ShellExecute(
NULL,
_T("open"),
_T("C:\connect\connect.exe"),
_T("J11"),
NULL,
SW_SHOW);
是的,差异非常大。
CMD处理您键入的内容,然后将其传递给CreateProcessEx。CMD的"开始"命令,运行对话框或双击文件,将传递给ShellExecuteEx函数之一,该函数又调用CreateProcessEx。
有关CMD,请参阅Windows NT Shell Scripting,第2章,Tim Hill(1998)的Windows NT Command Shell,可从MS的网站获得(只有该章是免费提供的)。CMD对传递给CreateProcessEx的内容进行了详细的预处理。CMD也拥有ShellExecute的仿真,但它是在Windows 95规则下ShellExecute,而不是经常更新的shell32实现。
有关 ShellExecute,请参阅ShellExecuteEx
文档。
要查看CreateProcessEx
规则,请参阅其文档。
我打算粘贴规则,但CMD跑到页面。
返回值告诉您命令不起作用的原因。
返回值
如果成功,则返回大于 32的值,否则返回小于或等于 32 的错误值。下表列出了错误值。返回值转换为 HINSTANCE,以便向后兼容 16 位 Windows 应用程序。然而,它不是一个真正的HINSTANCE。返回的 HINSTANCE 唯一可以做的是将其转换为 int 并将其与值 32 或下面的错误代码之一进行比较。
0 The operating system is out of memory or resources.
ERROR_FILE_NOT_FOUND The specified file was not found.
ERROR_PATH_NOT_FOUND The specified path was not found.
ERROR_BAD_FORMAT The .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image).
SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid.
SE_ERR_DDEBUSY The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed.
SE_ERR_DDEFAIL The DDE transaction failed.
SE_ERR_DDETIMEOUT The DDE transaction could not be completed because the request timed out.
SE_ERR_DLLNOTFOUND The specified DLL was not found.
SE_ERR_FNF The specified file was not found.
SE_ERR_NOASSOC There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
SE_ERR_OOM There was not enough memory to complete the operation.
SE_ERR_PNF The specified path was not found.
SE_ERR_SHARE A sharing violation occurred.
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- 如果没有malloc,链表实现将失败
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- int(c) 和 c-'0' 之间的区别。C++
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 使用 std::move 将参数传递给函数,如果该参数声明为按值传递或使用移动操作数 &&,是否有区别?
- 如果我提前将参数声明为变量而不是将它们内联写入函数调用,那有什么区别(在内存方面)?
- 对于属性上的 NOTIFY 信号,如果我给它一个参数有什么区别?
- 对于数据成员,如果包含对象已在动态内存中,则动态分配此变量(或不动态分配)之间是否有任何区别
- 如果和同时中断之间的区别
- 如果"foo"是引用变量,[&foo]{ ... } 捕获和 [foo]{ ... } 捕获之间有区别吗?
- C++数组运算符和 *(数组 + 索引)之间有什么区别(如果有)
- ShellExecute和CMD命令之间有什么区别,如果有的话
- {x} 和 '= {x}' 初始化之间有什么区别(如果有的话)?
- 如果我们只有一个成员,那么结构和工会之间有什么区别吗
- 如果 a 是 cv::Mat 和 cv::Mat b=a.row(1),那么两个 cv::Mat 实例有什么区别
- 如果f是双精度数,f+=1和f+=1.0有什么区别吗?
- 如果两者都以相同的方式工作,那么使用 void func(struct myStruct s) 和 void func(myStruct s) 有什么区别?