CreateProcess() Error

一笑奈何 提交于 2019-11-29 12:48:14

You use the L prefix to make a wide character string:

L"D:\\test dir 1\\Calc.exe";

Casting a string literal to a different character width does not make a string wider.

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."

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!