CreateProcess succeeds, but GetLastError() returns access denied

后端 未结 2 1135
日久生厌
日久生厌 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:12

    GetLastError is only meaningful when the documentation states it is meaningful.

    GetLastError returns the Win32 thread last error set with SetLastError. Since functions are only supposed to set or clear the last error when it is documented that they do so, if that hasn't happened, the last error may well contain an earlier error which is not relevant.

    It is documented that CreateProcess will set the last error if it fails, not if it succeeds. So you should ignore it.

提交回复
热议问题