这2种使用 CreateProcess的方法有什么区别吗,为什么第一种方法就可以执行,第二种方法不可以呢?               
                CreateProcess(NULL, //   pointer   to   name   of   executable   module   
"I:\\C++test\\testComdline\\Debug\\a.exe Comdline TRUE", //   command   line     
NULL, //   pointer   to   process   security   attributes     
NULL, //   pointer   to   thread   security   attributes   
FALSE, //   inherit   handles   
0, //   creation   flags   
NULL, //   pointer   to   new   environment   block   (use   parent's)   
NULL,   
&StartupInfo, //   pointer   to   STARTUPINFO   
&ProcessInfo //   pointer   to   PROCESS_INFORMATION   
); CreateProcess("I:\\C++test\\testComdline\\Debug\\a.exe", //   pointer   to   name   of   executable   module   
"Comdline TRUE", //   command   line     
NULL, //   pointer   to   process   security   attributes     
NULL, //   pointer   to   thread   security   attributes   
FALSE, //   inherit   handles   
0, //   creation   flags   
NULL, //   pointer   to   new   environment   block   (use   parent's)   
NULL,   
&StartupInfo, //   pointer   to   STARTUPINFO   
&ProcessInfo //   pointer   to   PROCESS_INFORMATION   
);

解决方案 »

  1.   

    应用程序对这2中情况的翻译如下
    第一种:
       arg[0] = "I:\\C++test\\testComdline\\Debug\\a.exe "
       arg[1] = "Comdline TRUE"
    第二种:
       arg[0] = "Comdline TRUE"所以就导致了如上结果
    见CreateProcess 创建32位进程行为
      

  2.   

    哦 可能说错了 
    刚去查了下MSDN
    If both lpApplicationName and lpCommandLine are non-NULL, the null-terminated string pointed to by lpApplicationName specifies the module to execute, and the null-terminated string pointed to by lpCommandLine specifies the command line. The new process can use GetCommandLine to retrieve the entire command line. Console processes written in C can use the argc and argv arguments to parse the command line. Because argv[0] is the module name, C programmers generally repeat the module name as the first token in the command line.
      

  3.   

    是不是你没有使用GetCommandLine
      

  4.   

    If the executable module is a 16-bit application, lpApplicationName should be NULL, and the string pointed to by lpCommandLine should specify the executable module as well as its arguments.
      

  5.   

     command  line    方式不是这样写的吧
      

  6.   

    第二种方法改成:
    CreateProcess("I:\\C++test\\testComdline\\Debug\\a.exe", //  pointer  to  name  of  executable  module  
    "I:\\C++test\\testComdline\\Debug\\a.exe Comdline TRUE", //  command  line    
    NULL, //  pointer  to  process  security  attributes    
    NULL, //  pointer  to  thread  security  attributes  
    FALSE, //  inherit  handles  
    0, //  creation  flags  
    NULL, //  pointer  to  new  environment  block  (use  parent's)  
    NULL,  
    &StartupInfo, //  pointer  to  STARTUPINFO  
    &ProcessInfo //  pointer  to  PROCESS_INFORMATION  
    );
    这个函数第一个参数是可执行文件的路径,它是不包含命令行参数的。而第二个参数是启动进程时使用的命令行,这个命令行必须含有可执行文件的路径,这个exe文件的路径将作为子进程的第一个命令行参数。