if (!::CreateProcess(sTempFile,NULL,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi_winkey))
想问下这句话什么意思呢? 是说"如果创建线程失败"的意思吗?
还有就是那个sTempFile,网上说是可执行模块的路径,如果是c:\\aaa.bat 但是我去看C盘里面  没有这个东西, 是不是这个函数就会失败? 还是说它会自己创建这个吗? 不知道问错没。

解决方案 »

  1.   

    pszImageName 
    [in] Pointer to a null-terminated string that specifies the module to execute. 
    The string can specify the full path and filename of the module to execute or it can specify a partial path and filename. The lpszImageName parameter must be non-NULL and must include the module name. pszCmdLine 
    [in, out] Pointer to a null-terminated string that specifies the command line to execute. 
    The system adds a null character to the command line, trimming the string if necessary, to indicate which file was used. The lpszCmdLine parameter can be NULL. In that case, the function uses the string pointed to by lpszImageName as the command line. If lpszImageName and lpszCmdLine are non-NULL, * lpszImageName specifies the module to execute, and * lpszCmdLine specifies the command line. C runtime processes can use the argc and argv arguments. If the filename does not contain an extension, .EXE is assumed. If the filename ends in a period (.) with no extension, or if the filename contains a path, .EXE is not appended. psaProcess 
    [in] Not supported; set to NULL. 
    psaThread 
    [in] Not supported; set to NULL. 
    fInheritHandles 
    [in] Not supported; set to FALSE. 
    fdwCreate 
    [in] Specifies additional flags that control the priority and the creation of the process. 
    The following creation flags can be specified in any combination, except as noted. Value Description 
    CREATE_DEFAULT_ERROR_MODE Not supported. 
    CREATE_NEW_CONSOLE The new process has a new console, instead of inheriting the parent's console.  
    CREATE_NEW_PROCESS_GROUP Not supported. 
    CREATE_SEPARATE_WOW_VDM Not supported. 
    CREATE_SHARED_WOW_VDM Not supported. 
    CREATE_SUSPENDED The primary thread of the new process is created in a suspended state, and does not run until the ResumeThread function is called. 
    CREATE_UNICODE_ENVIRONMENT Not supported. 
    DEBUG_PROCESS If this flag is set, the calling process is treated as a debugger, and the new process is a process being debugged. Child processes of the new process are also debugged. 
    The system notifies the debugger of all debug events that occur in the process being debugged.If you create a process with this flag set, only the calling thread (the thread that called CreateProcess) can call the WaitForDebugEvent function.
     
    DEBUG_ONLY_THIS_PROCESS If this flag is set, the calling process is treated as a debugger, and the new process is a process being debugged. No child processes of the new process are debugged. 
    The system notifies the debugger of all debug events that occur in the process being debugged.
     
    DETACHED_PROCESS Not supported. 
    INHERIT_CALLER_PRIORITY If this flag is set, the new process inherits the priority of the creator process. Windows CE does not support the concept of a priority class. The priority of a thread is the only parameter that determines a thread's scheduling priority. pvEnvironment 
    [in] Not supported; set to NULL. 
    pszCurDir 
    [in] Not supported; set to NULL. 
    psiStartInfo 
    [in] Not supported; set to NULL. 
    pProcInfo 
    [out] Pointer to a PROCESS_INFORMATION structure that receives identification information about the new process. 
    Return Values
    Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
      

  2.   

    CreateProcess是启动进程,你都没有aaa.bat这个文件那怎么会成功呢?更不会去创建了。所以会失败,GetLastError返回值看看就比较清楚了
      

  3.   

    if (!::CreateProcess(sTempFile,NULL,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi_winkey))
    =====================
    这个是启动一个外部的进程,sTempFile是你要启动的程序的路径,不是创建文件的。