WinExec函数,启动其他应用程序
[in] Pointer to a null-terminated character string that contains the command line (file name plus optional parameters) for the application to be executed. If the name of the executable file in thelpCmdLine parameter does not contain a directory path, the system searches for the executable file in this sequence: The directory from which the application loaded. The current directory. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory. The directories listed in the PATH environment variable.
[in] Specifies how a Windows-based application window is to be shown and is used to supply the wShowWindow member of the STARTUPINFO parameter to the CreateProcess function. For a list of the acceptable values, see the description of the nCmdShow parameter of the ShowWindow function. For a non-Windows – based application, the PIF file, if any, for the application determines the window state.
Return Values
If the function succeeds, the return value is greater than 31.
If the function fails, the return value is one of the following error values:
Remarks
The WinExec function returns when the started process calls the GetMessage function or a time-out limit is reached. To avoid waiting for the time out delay, call the GetMessage function as soon as possible in any process started by a call to WinExec.
Security RemarksThe executable name is treated as the first white space-delimited string in lpCmdLine. If the executable or path name has a space in it, there is a risk that a different executable could be run because of the way the function parses spaces. The following example is dangerous because the function will attempt to run "Program.exe", if it exists, instead of "MyApp.exe".
WinExec("C:\Program Files\MyApp", ...)
If a malicious user were to create an application called "Program.exe" on a system, any program that incorrectly calls WinExec using the Program Files directory will run this application instead of the intended application.
To avoid this problem, use CreateProcess rather than WinExec. However, if you must use WinExec for legacy reasons, make sure the application name is enclosed in quotation marks as shown in the example below.
WinExec("\"C:\Program Files\MyApp.exe\" -L -S", ...)
相关文章
- Awesome Mac:收集的非常全面好用的Mac应用程序、软件以及工具
- Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer 关于Newtonsoft.Json,LINQ to JSON的一个小demo mysql循环插入数据、生成随机数及CONCAT函数 .NET记录-获取外网IP以及判断该IP是属于网通还是电信 Guid的生成和数据修整(去除空格和小写字符)
- .NET Core快速入门教程 4、使用VS Code开发.NET Core控制台应用程序
- 安卓 和 Linux 之间传输文件的 8 个应用程序
- 如何开展移动应用程序性能测试?
- MFC获得当前应用程序目录的GetCurrentDirectory()和GetModuleFileName()函数
- Android系统默认Home应用程序(Launcher)的启动过程源代码分析
- JS教程之使用 ElectronJS、VueJS、SQLite 和 Sequelize ORM 从 A 到 Z 创建多对多 CRUD 应用程序
- 测试Web应用程序的基本要素
- web应用程序访问串口
- Unity 之 Mac在其他电脑安装不成功,弹出“XXX”安装不上时 和 没有权限打开应用程序
- 浅析 - iOS应用程序的生命周期
- Winform应用程序实现通用遮罩层