About Handles and Objects
Windows uses objects and handles to regulate access to system resources for
two main reasons. First, the use of objects ensures that developers are not
writing code specifically to low-level, internal structures. This enables Microsoft
to add or change functionality of the operating system, as long as the original
calling conventions are maintained. When subsequent versions of the operating
system are released, applications will gain this new functionality with little
or no additional development.
Second, the use of objects enables developers to take advantage of Win32
security. Each object has its own access-control list (ACL) that specifies the types
of actions processes can perform on the object. The operating system examines
an object's ACL each time an application attempts to create a handle to the
object. For more information about security, see
Security.
For most objects, the Win32 API provides functions that create the object,
create an object handle, close the object handle, and destroy the object. These
tasks may be combined or unnecessary, depending on the type of object and the
situation. For example, an application could create an event object. Other
applications could open the event and each would have a unique handle to the same
event object. In this scenario, as the applications finish using the object, each
closes its handle. When there are no open handles to the event object, the
operating system removes the object from memory.
In contrast, an application could obtain the existing window-object handle. In
this instance, when the window object is no longer needed, the application
must remove the object from memory, which invalidates the window handle.
When a process terminates, the system automatically closes handles and deletes
objects created by the process. However, when a thread terminates, the system
usually does not close handles or delete objects. The only exceptions are
window, hook, window position, and dynamic data exchange (DDE) conversation objects
that are deleted when the creating thread terminates.
Handles and objects consume memory. Therefore, to preserve system performance,
an application should close handles and delete objects as soon as they are no
longer needed. Applications that do not do this can slow the operating system,
due to excessive use of the paging file.
Windows provides three categories of objects: user, graphics device interface
(GDI), and kernel, as shown in the following tables. The system uses user
objects to support window management, GDI objects to support graphics, and kernel
objects to support memory management, process execution, and interprocess
communications (IPC). For information about creating and using a specific object,
refer to the associated overview.
Windows User Objects
Windows GDI Objects
Windows Kernel Objects
- Software for developers
-
Delphi Components
.Net Components
Software for Android Developers
- More information resources
-
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
- Databases for Amazon shops developers
-
Amazon Categories Database
Browse Nodes Database