UINT WinExec(lpszCmdLine, fuCmdShow) | |||||
LPCSTR lpszCmdLine; | /* address of command line | */ | |||
UINT fuCmdShow; | /* window style for new app. | */ |
The WinExec function runs the specified application.
This function is obsolete. Applications should use the CreateProcess function.
For compatibility with earlier versions of Windows, this function is implemented in Win32 by calling the CreateProcess function. The following list describes how each parameter for the CreateProcess function is formed:
CreateProcess parameter | Value |
lpszImageName | NULL |
lpszCommandLine | WinExec lpszCmdLine parameter |
lpsaProc | NULL |
lpsaThread | NULL |
fInheritHandles | FALSE |
fdwCreate | 0 |
lpvEnvironment | NULL |
lpszCurDir | NULL |
lpsi | The structure is initialized to zero. The cb field is set to the size of the structure, and the wShowWindow field is set to the value of the WinExec fuCmdShow parameter. |
lppi->hProcess | The handle is immediately closed. |
lppi->hThread | The handle is immediately closed. |
lpszCmdLine
Points to a null-terminated character string that contains the command line (filename plus optional parameters) for the application to be executed. If the lpszCmdLine string does not contain a directory path, Windows will search for the executable file in this order:
1.The current directory
2.The Windows system directory (the directory containing such system files as KERNEL.EXE); the GetSystemDirectory function obtains the pathname of this directory
3.The Windows directory (the directory containing WIN.COM); the GetWindowsDirectory function obtains the pathname of this directory
4.The directories listed in the PATH environment variable
fuCmdShow
Specifies how a Windows application window is to be shown. See the description of the ShowWindow function for a list of the acceptable values for the fuCmdShow parameter. For a non-Windows application, the PIF file, if any, for the application determines the window state.
The return value is 32 if the function was successful. Otherwise, it is an error code, which may be one of the following:
Value | Meaning |
0 | Out of memory or system resources. |
ERROR_FILE_NOT_FOUND | The specified file could not be found. |
ERROR_PATH_NOT_FOUND | The specified path could not be found. |
ERROR_BAD_EXE_FORMAT | Invalid .EXE file (non-Win32 .EXE or error in .EXE image). |
CreateProcess, GetSystemDirectory, GetWindowsDirectory, LoadModule, ShowWindow