CreateProcess succeeds, but GetLastError() returns access denied

后端 未结 2 1119
日久生厌
日久生厌 2021-01-15 21:26

I\'m having a little confusion due to conflicting return values from CreateProcess() and GetLastError(). When I use CreateProcess() in

2条回答
  •  [愿得一人]
    2021-01-15 22:15

    From the documentation of GetLastError

    The Return Value section of the documentation for each function that sets the last-error code notes the conditions under which the function sets the last-error code. Most functions that set the thread's last-error code set it when they fail. However, some functions also set the last-error code when they succeed. [emphasis mine]

    I think you get the experienced outcome because, uppon success, CreateProcess does not set the error value GetLastError returns. Instead your call to GetLastError returns an error set by another function called earlier

提交回复
热议问题