WORD WinExec(lpCmdLine,nCmdShow)
This function executes the Windows or non-Windows application identified by the lpCmdLine parameter. The nCmdShow parameter specifies the initial state of the application's main window when it is created.
Parameter | Type/Description |
lpCmdLine | LPSTR Points to a null-terminated character string that contains the command line (filename plus optional parameters) for the application to be executed. If the lpCmdLine string does not contain a directory path, Windows will search for the executable file in this order: | |
1.The current directory | ||
2.The Windows directory (the directory containing WIN.COM); the GetWindowsDirectory function obtains the pathname of this directory | ||
3.The Windows system directory (the directory containing such system files as KERNEL.EXE); the GetSystemDirectory function obtains the pathname of this directory | ||
4.The directories listed in the PATH environment variable | ||
5.The list of directories mapped in a network | ||
If the application filename does not contain an extension, then .EXE is assumed. | ||
nCmdShow | int 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 nCmdShow parameter. For a non-Windows application, the PIF file, if any, for the application determines the window state. |
The return value specifies whether the function was successful. If the function was successful, the return value is greater than 32. Otherwise, it is a value less than 32 that specifies the error. The following list describes the error values returned by this function:
Value | Meaning |
0 | Out of memory. |
2 | File not found. |
3 | Path not found. |
5 | Attempt to dynamically link to a task. |
6 | Library requires separate data segments for each task. |
10 | Incorrect Windows version. |
11 | Invalid .EXE file (non-Windows .EXE or error in .EXE image). |
12 | OS/2 application. |
13 | DOS 4.0 application. |
14 | Unknown .EXE type. |
15 | Attempt in protected (standard or 386 enhanced) mode to load an .EXE created for an earlier version of Windows. |
16 | Attempt to load a second instance of an .EXE containing multiple, writeable data segments. |
17 | Attempt in large-frame EMS mode to load a second instance of an application that links to certain nonshareable DLLs already in use. |
18 | Attempt in real mode to load an application marked for protected mode only. |
The LoadModule function provides an alternative method for executing a program.