EOSError
Delphi Programming Language
Severity: ModerateWhat Does This Error Mean?
EOSError is raised when a Windows operating system call fails. Delphi wraps many OS API calls, and when Windows returns an error code, Delphi converts it to an EOSError exception. The ErrorCode property contains the Windows error number, and the Message property contains a description of what went wrong.
Affected Models
- All Delphi versions on Windows
- RAD Studio Windows targets
Common Causes
- Trying to access a file or folder that does not exist or requires administrator privileges
- Registry access failing due to insufficient permissions
- A Windows API call returning an error (like CreateProcess, OpenProcess, or a handle operation)
- Network path not accessible — mapped drives or UNC paths that are not connected
- Running the application on a Windows version that does not support the API being called
How to Fix It
-
Read E.ErrorCode and E.Message. The message is a human-readable Windows error description. Common codes: 2 = file not found, 5 = access denied, 32 = file in use, 87 = invalid parameter.
You can also get the message text in code: SysErrorMessage(E.ErrorCode)
-
If ErrorCode is 5 (Access Denied), the operation requires elevated privileges. Try running the application as Administrator, or use the file/resource from a location that does not require admin access.
Right-click the EXE and choose 'Run as administrator' to test this.
-
If ErrorCode is 2 (File Not Found) or 3 (Path Not Found), verify the path exists. Use FileExists() or DirectoryExists() before attempting the operation.
Also check for network paths — a mapped drive that is not connected returns these error codes.
-
If ErrorCode is 32 (File Is Being Used by Another Process), the file is locked. Wait and retry, or find and close the other process that has the file open.
The Microsoft utility 'Process Explorer' (from Sysinternals) can show which process has a file locked.
-
For registry operations (using TRegistry), make sure you are opening the right key with the right access rights. Use KEY_READ for reading, KEY_WRITE for writing — not both when only one is needed.
On 64-bit Windows, also check KEY_WOW64_64KEY vs KEY_WOW64_32KEY if your registry key is in a virtualized location.
When to Call a Professional
Most EOSError cases are fixable yourself once you know the error code. The ErrorCode property matches the standard Windows error codes. Run the application as Administrator if the error code is 5 (Access Denied).
Frequently Asked Questions
Where can I find a list of all Windows error codes?
Microsoft maintains the official list at learn.microsoft.com. Search for 'Windows system error codes' to find the full list. You can also look up any error code in code using FormatMessage() or Delphi's SysErrorMessage(). Common ones are also documented in the WinError.h header file.
Why does my Delphi app work on my PC but get EOSError on the client's PC?
Often because you are running as Administrator on your PC but the client is not. Or the client's PC has a different Windows version, different file paths, or stricter security policies. Always test on a standard user account — not Administrator — to catch permission issues early.
Is EOSError the same as EInOutError?
They are related but different. EInOutError is specifically for classic Pascal file I/O operations (AssignFile, Reset, etc.). EOSError is for Windows OS API calls in general — file system, registry, process management, handles. Both descend from the same base, but they come from different parts of Delphi's runtime library.