开发者

Confusion over Win32 CreateProcess

I am confused by the first 2 params, module and command-line. I find unless I populate both it doesn't work right, and it seems the documentation says otherwise.

I want to call "testApp.exe param1=123"

The only way I found that works is:

CreateProcess("te开发者_运维问答stApp.exe","testApp.exe param1=123",...

I thought either of these should work, but no luck so far:

CreateProcess("testApp.exe","param1=123",...
CreateProcess(NULL,"testApp.exe param1=123",...

I've read the msdn docs a few times so what am I missing?


The first parameter is the name of the executable to run. The second parameter is the command line. The command-line need not contain the name of the executable, if it doesn't however and you pass something like

"param1 param2"

then in your program, argv[0] == "param1" and argv[1] == "param2". Therefore, you usually have to pass the name of the executable as the first value to satisfy the program's requirements, not Windows'.

If you do not pass the executable name, it is extracted from the first value in the command line string.


I discuss issues with getting CreateProcess to run exes in an article here. There are multiple things that can go wrong, including the requirement for fully qualified paths, and absent exe names in the command line.


Instead of giving name of executable try to give full path with name of executable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜