Back to List
You are viewing an unformatted version of this file.
# Error: The operation completed successfully
[You can look up various error codes here](/winerr/).
Most people have experienced this or similar weird messages at least once.
Here's an explanation why there is a "success error"
Badly programmed error checking or an unexpected condition.
## The number `0`
It's the result of the number `0` being used as error code.
![Error code 0](data/error_0.png)
Here is an explanation why this happens. There are two main reasons:
## A: Give error code as result of a function
When a function says it returns an error code it has to return one,
there is no "I don't have one this time" value because there is no integer value for "no integer".
It's common to return `0` when the operation completed successfully and a different number otherwise.
One of the most common codes people see is `5` (or `0x5`) which means "Access Denied".
This scenario can go wrong in two common ways:
The function returned `0` but the program tests for success in another way, for example if a certain file is there after installation.
The developer did not implement a check for a function because "it should never fail",
but when it eventually does fail, dependent actions do nothing and you check the wrong error code.
Some functions reset the code to `0`.
## B: Windows Error Code
Sometimes you want to return something more complex than numbers,
but processors only allow integers as function results.
In that case you store the complex result in memory and return the memory location where you put it.
It's common to return `0` if nothing was put in memory (usually because of an error).
This means you need to have a different error reporting mechanism.
In Windows, each thread can do `SetLastError(error_code)` and `GetLastError()`.
Some functions set this to `0` on success,
some only set it when they fail and otherwise leave it unchanged.
## Origin of the text
Windows has a function that retrieves the message for a given error code.
Programmers don't put these messages in,
Windows has them already and they added the message for `0`.
These messages are always in the language of the operating system and thus might show in a different language.
An english application will still show german messages if Windows is set to german.