WinExec

WinExec、ShellExecute用法详解

小云
184
2023-09-13 07:10:38
栏目: 编程语言
Windows服务器0元免费领,领完即止! 查看>>

WinExec和ShellExecute是Windows操作系统中的两个函数,用于执行外部程序或打开文件。下面是它们的用法详解:

  1. WinExec函数:
#include <windows.h>
int main()
{
WinExec("notepad.exe", SW_SHOW);
return 0;
}
  1. ShellExecute函数:
#include <windows.h>
int main()
{
ShellExecute(NULL, "open", "notepad.exe", NULL, NULL, SW_SHOW);
return 0;
}

使用WinExec或ShellExecute函数可以执行外部程序或打开文件,具体使用哪个函数取决于具体的需求。如果只需要简单执行一个外部程序,建议使用WinExec函数;如果需要更多的操作选项,比如指定父窗口、传递命令行参数等,可以使用ShellExecute函数。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

相关推荐:qt中WinExec、ShellExecute的用法是什么

0
看了该问题的人还看了