User objects support only one handle per object. Processes cannot inherit or duplicate handles to user objects. There is no per-process limit on user handles, but there is a system-wide limit of 65,536 user handles.
Handles to user objects are public to all processes. That is, any process can use the user object handle, provided that the process has security access to the object.
In the following illustration, an application creates a window object. The CreateWindow function creates the window object and returns an object handle.
After the window object has been created, the application can use the window handle to display or change the window. The handle remains valid until the window object is destroyed.
In the next illustration, the application destroys the window object. The DestroyWindow function removes the window object from memory, which invalidates the window handle.
The following table lists the user objects, along with each object's creator and destroyer functions. The creator functions either create the object and an object handle or simply return the existing object handle. The destroyer functions remove the object from memory, which invalidates the object handle.
User Objects
Object | Creator function | Destroyer function |
---|---|---|
Accelerator table | CreateAcceleratorTable | DestroyAcceleratorTable |
Caret | CreateCaret | DestroyCaret |
Cursor | CreateCursor, LoadCursor, LoadImage | DestroyCursor |
DDE conversation | DdeConnect, DdeConnectList | DdeDisconnect, DdeDisconnectList |
Desktop | GetThreadDesktop | Applications cannot delete this object. |
Hook | SetWindowsHookEx | UnhookWindowsHookEx |
Icon | CreateIconIndirect, LoadIcon, LoadImage | DestroyIcon |
Menu | CreateMenu, CreatePopupMenu, LoadMenu, LoadMenuIndirect | DestroyMenu |
Window | CreateWindow, CreateWindowEx, CreateDialogParam, CreateDialogIndirectParam, CreateMDIWindow | DestroyWindow |
Window position | BeginDeferWindowPos | EndDeferWindowPos |
Window station | GetProcessWindowStation | Applications cannot delete this object. |