 M: windows-io run-process* ( desc -- )
     [
         default-CreateProcess-args
-        fill-lpCommandLine
+        wince? [
+            fill-lpApplicationName
+        ] [
+            fill-lpCommandLine
+        ] if
         fill-dwCreateFlags
         fill-lpEnvironment
         dup call-CreateProcess

        CreateProcess-args-lpProcessInformation
    } get-slots CreateProcess win32-error=0/f ;

: fill-lpCommandLine
    +command+ get [
        [
            +arguments+ get [ CHAR: \s , ] [
                CHAR: " ,
                [ dup CHAR: " = [ CHAR: \\ , ] when , ] each
                CHAR: " ,
            ] interleave
        ] "" make
    ] unless* over set-CreateProcess-args-lpCommandLine ;

: fill-dwCreateFlags
    CREATE_UNICODE_ENVIRONMENT
    +detached+ get [ DETACHED_PROCESS bitor ] when
    over set-CreateProcess-args-dwCreateFlags ;


USING: alien alien.c-types arrays continuations destructors io
io.windows libc io.nonblocking io.streams.duplex windows.types
math windows.kernel32 windows namespaces io.launcher kernel
sequences windows.errors assocs splitting system ;
IN: io.windows.launcher

! From MSDN: "Handles in PROCESS_INFORMATION must be closed with CloseHandle when they are no longer needed."
