Paths and CreateProcess

前端 未结 4 2011
小蘑菇
小蘑菇 2021-01-15 16:46

I have a question regarding a symptom of my misuse of CreateProcess. I\'m using the lpcommandline parameter to feed the path to my executable and parameters. My misuse is t

4条回答
  •  [愿得一人]
    2021-01-15 17:30

    As the document Martin York linked to hinted, CreateProcess() has some behaviour for back-compat with pre-long-name programs.

    "c:\program files\sub dir\program name arg1 arg2" will look for:

    "c:\program.exe" files\sub dir\program name arg1 arg2
    "c:\program files\sub.exe" dir\program name arg1 arg2
    "c:\program files\sub dir\program.exe" name arg1 arg2
    "c:\program files\sub dir\program name.exe" arg1 arg2
    

    So if any of these files exist, Windows will to call them, not your program. Also, I would assume if you did not have read access to any of the folders these possible matches are in, CreateProcess() may fail out immediatly, instead of checking if you have read to the later possible matches. (Windows by default checks read access only the final folder.)

提交回复
热议问题