Displays the window as a minimized window. Tłiis value is similar to SW_SHOWMINIMIZED, except the window is not activated.
SVV_SHO\VNA
Displays tlie window in its current size and position. Tliis value is similar to SW_SH O W, except tlie window is not activated.
SW_SH O WNO ACTIVATE
Displays a window in its most recent size and position. Tliis value is similar to SW_SHOWNORM AL, except the window is not activated.
SW_ SHOWNORMAL
Activates and displays a window. If tlie window is minimized or maximized, the system restones it to its original size and position. An application should speeify tliis flag when displaying tlie window for the first time.
Return Value
If the function succeeds, tlie return value is greater than 31.
If the function fails, tlie return value is one of tlie following error values.
Return c«te''value_
o
E R ROR_B AD.FORM AT E R ROR_FŁE_NOT_FOU ND E R ROR_PATH _NOT_FOU ND
The system is out of memory or resomres.
The .exe file is invalid
The specified file was not found.
The specified patii was not found
Remarks
The WinExec function retums when tlie started process calls the GetMessage function or a time-out limit is reached. To avoid waiting for the time out delay, cali tlie GetMessage function as soon as possible in any process started by a cali to WinExec.
Security Remarks
The executable na me is treated as the first white space-delimited string in lpCmdLine. If the executable or patii name lias 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 FilesWMyApp",...)
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 tliis application instead of the intended application.
To avoid tliis problem, use CreateProcess ratlier than \VinExec. However, if you must use WinExec for legacy reasons, make surę the application name is enclosed in quotation marks as shown in the example below.
WinExec("\"C:\\Program Files\\MyApp.exe\" -L -S",...)
Example
YVinExec(" M yOtherProgram. exe", SW_SH OWNORM AL);
// Runs MyOtherProgram in normal window WinExec("notepad.exe Program.cpp", SH_SHOW);
// Runs notepad wliich opens Program.cpp