Using CreateProcess with multiple argv

I am trying to create a child process by passing in multiple argv.

I have parent.exe, child.exe, and a number value.

if I use

if( !CreateProcess(NULL,
"child.exe 15",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi )
)

It runs successful with any number I put in.

If i try

if( !CreateProcess(NULL,
"argv[1] argv[2]",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi )
)

I get an error that the process could not be created.

I have reviewed all the standard reference pages that are mentioned in the forums and search, but none have a working example of using multiple arg values.

the parent program will be launced using

parent.exe child.exe 5 (The number can be any number)

the child.exe and the number should be the values passed to the child program.

I have a feeling I am missing something simple but I am at a dead end.

Last edited on
So you're writting a program, that lanches a program, to launch a program or load a reasource from an executable?

Have you looked into IPC (Inter-Process Communication) as an alternative route? It won't fix the issue you have here but it would allow you to pass a string to the child process, and from the child process you could have another "CreateProcess(...)" call to launch with that string as an argument.

Did you write the Child Process?
Are you trying to just process two things at once? In which case a Thread would be a better option?

Can I ask what you're actually trying to do? There is probably a better way to go about it. We often think ourselves into corners and are unable to see the easier solutions.
you are correct. sorry for the delay. I eventually put the argv1 in place of the firt NULL and left the argv2 on the second line and it worked.
Topic archived. No new replies allowed.