C/C++ ShellExecuteEx调用exe可执行文件
2015-11-02 20:55
639 查看
本系列文章由 @YhL_Leo 出品,转载请注明出处。
文章链接: /article/3664571.html
以商业的软件Enblend为例,进行图像无缝拼接和匀光匀色,可以如下直接在Dos中使用命令行调用:
输入数据:
输出结果:
C/C++中,有几种方法可以直接调用可执行文件
两者的运行结果是完全一样的。如果编译遇到BUG:
对于
SHELLEXECUTEINFO 和 ShellExecuteEx的使用(CSDN)
SHELLEXECUTEINFO structure(Microsoft Developer Network)
除此外,C/C++中调用可执行
详细请阅读:
C++程序怎样调用exe可执行文件(SINA)
文章链接: /article/3664571.html
以商业的软件Enblend为例,进行图像无缝拼接和匀光匀色,可以如下直接在Dos中使用命令行调用:
[code]C:\...\Test> enblend -o blend.tif 0.tif 1.tif 2.tif 3.tif 4.tif
输入数据:
输出结果:
C/C++中,有几种方法可以直接调用可执行文件
exe,这里以最常用的
ShellExcecuteEx函数为例。上面使用命令行操作,可转化为:
[code]// ShellExcecuteEx call the Enblend.exe #include <windows.h> #include <shellapi.h> #include <stdio.h> #include <tchar.h> void main() { SHELLEXECUTEINFO shExecInfo = {0}; shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; shExecInfo.hwnd = NULL; shExecInfo.lpVerb = _T("open"); shExecInfo.lpFile = _T("C:\\Users\\Leo\\Desktop\\Test\\enblend.exe"); shExecInfo.lpParameters = _T("-o blend.tif 0.tif 1.tif 2.tif 3.tif 4.tif"); shExecInfo.lpDirectory = _T("C:\\Users\\Leo\\Desktop\\Test"); shExecInfo.nShow = SW_SHOW; shExecInfo.hInstApp = NULL; ShellExecuteEx(&shExecInfo); WaitForSingleObject(shExecInfo.hProcess,INFINITE); }
两者的运行结果是完全一样的。如果编译遇到BUG:
cannot convert from 'const char [7]' to 'LPCWSTR',请见博客Multi-Byte Character Set & Unicode Character Set。
对于
ShellExcecuteEx函数,感兴趣的可以阅读以下两篇文章:
SHELLEXECUTEINFO 和 ShellExecuteEx的使用(CSDN)
SHELLEXECUTEINFO structure(Microsoft Developer Network)
除此外,C/C++中调用可执行
exe文件的方法还有:
system函数
exec或者
execv函数
WinExec函数
CreateProcess函数
详细请阅读:
C++程序怎样调用exe可执行文件(SINA)
相关文章推荐
- SHELL脚本基础
- 手把手教你写shell脚本——shell循环结构
- C#调用PowerShell脚本
- Win32中调用其他应用程序的方法(函数)winexec,shellexecute ,createprocess
- 51nod 1070 Bash游戏 V4 (博弈论_找规律)
- PowerShell入门(一):PowerShell能干什么?
- shell 使用printf
- shell script 之test
- 希尔排序
- PowerShell入门(序):为什么需要PowerShell?
- 认识与学习shell
- Javaweb架构分析安全之万户ezoffice全版本通杀上传GETSHELL
- shell 命令行的学习
- linux基础 --- shell
- 通过PowerShell 脚本在中国区Azure部署定制化HDInsight 集群
- shell script 学习笔记-----命令执行
- 编译android出现 /bin/bash: jar: command not found; /bin/bash: javah: command not found解决办法
- shell获取ip地址
- xshell怎样打印
- 使用bash解析xml