I have a command,I need to execute the same using C Program. I have stored the e开发者_高级运维ntire command ,with arguments, in the variable cmdline. When I am using system(cmdline),it is working fine. But on using the following: ret = CreateProcess(NULL, cmdline, (LPSECURITY_ATTRIBUTES)NULL, (LPSECURITY_ATTRIBUTES)NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &pinfo);
I am getting the return code as 2 in GetLastError().
Can somebody tell the reason? Thanks in advance.
Maybe the program name contains whitespace?
From MSDN: If lpApplicationName is NULL, the first white-space – delimited token of the command line specifies the module name. If you are using a long file name that contains a space, use quoted strings to indicate where the file name ends and the arguments begin.
精彩评论