Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>winexec()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
WinExec()
Run a program
------------------------------------------------------------------------------

Syntax
WinExec( <cCommandLine>,  [ <nCmdShow> ]  )   -->   nStatus

Arguments
<cCommandLine> is the command line to be executed.  This
string can specify just a program name or a program and its
parameters.

<nCmdShow> is an optional parameter specifying how the
program's window is to be displayed.  (Use one of the SW_*
values defined in WINDOWS.CH, as also used for the ShowWindow()
function.)  The default is value SW_SHOWNORMAL.

Returns
The returned value is an integer specifying the handle to the
instance of the program, or an integer error code (if the
value is less than 32).

Description
If the command line does not specify a path to the program,
Windows tries the current directory, then the Windows
directory (as returned by the GetWindowsDirectory()
function), then the Windows system directory (as returned by
the GetSystemDirectory() function), then the directory
containing the application issuing the WinExec() call, then
the directories in the PATH, and finally any network-mapped
directories.

Note: if the program to be run is a .COM file you must specify
the .COM, as Windows assumes .EXE only.

If the program is started successfully, it is run at the same
time as the existing application (Windows does not wait for
the new program to exit before returning to the existing
program).

The error codes are as follows:

     <nStatus>      means

          0         out of memory, or invalid executable file

          2         program not found

          3         invalid path

          5         sharing or network violation

          6         a library error

          8         out of memory

          10        wrong Windows version for the application

          11        invalid executable file

          12        wrong operating system for application

          13        MS-DOS 4.0 only application

          14        unknown executable file version

          15        a real-mode Windows application

          16        attempt to run multiple copies of an application
                    with multiple data segments

          19        trying to run a compressed executable file

          20        a required DLL was invalid (corrupt)

          21        32-bit Windows extensions required

Example
if WinExec( "command.com" ) < 32
     // failed
endif


See Also: ShowWindow()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson