PRB: Writing to Resources May Change Last Error (137289)
The information in this article applies to:
- Microsoft Platform Software Development Kit (SDK) 1.0, when used with:
- the operating system: Microsoft Windows 2000
This article was previously published under Q137289 SYMPTOMS
When writing to an application's resources, the value returned by
GetLastError may change. This behavior occurs in Windows 95, Windows 98 and Windows 2000, but not in Windows NT.
CAUSE
When an application writes to its own resources, a page fault occurs, which
is handled internally by the kernel. The handling of this page fault may
change the value returned by GetLastError.
RESOLUTION
To avoid this problem:
- Don't write to your own resources. The pointer returned by LockResource
should be treated as read-only. This was always the intention, however,
writing to your own resources happens to work on Windows NT.
- If you really need to write to your own resource, do not rely on the
last error being preserved. If the value returned by GetLastError is
important to you, call GetLastError before writing to your own resource.
Then call SetLastError to restore the value after you are finished.
STATUS
This behavior is by design.
MORE INFORMATION
It is legitimate for an API to change the last error even when it is
successful.
Modification Type: | Minor | Last Reviewed: | 7/11/2005 |
---|
Keywords: | kbprb kbResource KB137289 |
---|
|