_spawn (msvcrt)
Last changed: -86.12.217.228

.
Summary
spawn, wspawn Functions

C# Signature:

[DllImport("msvcrt.dll", CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr _wspawnl(
         int mode,  // _P_ constant (_P_WAIT=0, _P_NOWAIT=1)
         [MarshalAs(UnmanagedType.LPWStr)]string cmdname,
         [MarshalAs(UnmanagedType.LPWStr)]string arg0,
         [MarshalAs(UnmanagedType.LPWStr)]string arg1,
         [MarshalAs(UnmanagedType.LPWStr)]string argNULL);

VB Signature:

Declare Function _spawn Lib "msvcrt.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

C# Sample Code

    [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
    static extern IntPtr _wspawnl(
         int mode,  // _P_ constant (_P_WAIT=0, _P_NOWAIT=1)
         [MarshalAs(UnmanagedType.LPWStr)]string cmdname,
         [MarshalAs(UnmanagedType.LPWStr)]string arg0,
         [MarshalAs(UnmanagedType.LPWStr)]string arg1,
         [MarshalAs(UnmanagedType.LPWStr)]string argNULL);
    static int _P_WAIT = 0;     // Suspends calling thread until execution of new process
                    // is complete (synchronous _spawn).
    static int _P_NOWAIT = 1;   // Continues to execute calling process concurrently with
                    // new process (asynchronous _spawn).
    static int _P_OVERLAY = 2;  // Overlays calling process with new process, destroying
                    // the calling process (same effect as _exec calls).
    static int _P_NOWAITO = 3;  // Continues to execute calling process concurrently with
                    // new process (asynchronous _spawn).
    static int _P_DETACH = 4;   // Continues to execute the calling process; new process
                    // is run in the background with no access to the console
                    // or keyboard. Calls to _cwait against the new process will
                    // fail (asynchronous _spawn).

    // start process AppName and destroy the current process
    _wspawnl(_P_OVERLAY, AppName, "", "", null);

Documentation
_spawn on MSDN