CreateProcess() Error

前端 未结 2 451
无人共我
无人共我 2020-12-20 07:28
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
si.cb = sizeof(si);

LPCWSTR procName =(LPCWSTR)\"D:\\\\test          


        
2条回答
  •  失恋的感觉
    2020-12-20 08:05

    In addition to the string type issue already pointed out, the second argument (lpCommandLine) must point to a writable buffer, not a constant string. You can do this by declaring it as follows:

    WCHAR procArg[] = L"blacknull";
    

    This is documented in MSDN: "The Unicode version of this function, CreateProcessW, can modify the contents of this string. Therefore, this parameter cannot be a pointer to read-only memory (such as a const variable or a literal string). If this parameter is a constant string, the function may cause an access violation."

提交回复
热议问题