Windows API - CreateProcess() path with space

前端 未结 5 1978
春和景丽
春和景丽 2021-01-11 13:57

How do I pass path with space to the CreateProcess() function?

The following works

STARTUPINFO si;
            PROCESS_INFORMATION pi;

            Z         


        
5条回答
  •  余生分开走
    2021-01-11 14:15

    Your 3rd snippet is the correct one, not sure why you have trouble. Having the GetLastError() return value would be valuable here. Do note however that the 2nd argument of CreateProcess is an LPTSTR, not an LPCTSTR. In other words, Windows can write back to the string. Pretty creepy, isn't it? Enough reason perhaps to use ShellExecuteEx() instead.

提交回复
热议问题