Microsoft Development
--
Questions
--
Followers
Top Experts
the meaning of "handle".is it a pointer or address?
Could you tell me more about handle?Thank you!
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
There are (at least) 3 different kind of handles in windows:
- GDI handles
- Kernel/System handles
- User handles
GDI handles are already explained by FengYuan in depth. User handles are Window handles and such. Then we have Kernel/System handles, which are all those kind of handles which you can close with "CloseHandle". Examples are process handles, thread handles, file handles, event handles, socket handles and much more. A kernel handle is something like an index into an internal handle table of the current process (that means a kernel handle is only valid in one process). A kernel handle points to a specific kernel object and grants access to this object with specific access rights. You can have several handles for the same kernel object, each handle with a different (or with the same) access mask. Some objects get destroyed in the moment when the last handle to them is closed (e.g. events, mutexes and such), others do not (e.g. processes/threads).
In the win9x family handles are a restricted resource. E.g. when you look at the CreateWindow documentation, you'll see that win9x only supports 16K user handles. So in win9x you have to be very careful about handles. In winNT handles are not restricted.
When your process terminates (regardless whether crashing or not), Windows closes all kernel and user handles that you have opened. I'm not sure about GDI handles. FengYuan?
Regards, Madshi.
If you want to write data to a file on disk, you only refer to the file by its real name once, when you open it. The action of opening the file means Windows gives a handle to the open file - a handle is a pointer to the open file, stored internally in windows. Whenever you read or write to the open file, you don't use the file name, you just use the handle that windows gave you instead, and Windows handles moving the data on and off the disk.
Similar is when you have asked Windows to create a new window for you, or another object. Windows handles the manipulation of the object for you, and you just refer to the object by the handle Windows gave you when you first opened/created the object.
On Windows NT/2000, GDI/USER handles still have system-wide limitation, because of its table-based implementation. GDI handles are still limited to 16384 handles.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Thanx for the info.
>> On Windows NT/2000, GDI/USER handles still have system-wide limitation, because of its table-based implementation. GDI handles are still limited to 16384 handles.
:-(
Don't worry about the internal representation of handles.
eg: you may create more thon one windows( I mean a window that appears on screen) in your program. Now you wish to draw on a window. which window???. How do u tell windows Operating system to draw on window-1 of the program??.
When you give the handle of window-1 to say a function like TextOut text is displayed in window-1. If u give handle of window-2 text will be drawn on window-2.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
ignore it. Here is th rectified comment.
A handle is used to identify an object by windows. It is a number used internally by windows. Such numbers
are #defined in "Windows.h" and other header files used by windows.
Don't worry about the internal representation of handles.
It is not important as it is used internally by windows.
eg: you may create more thon one windows( I mean a window that appears on screen) in your program. Now
you wish to draw on a window. which window???. How do u tell windows Operating system to draw on window-1
of the program??.
When you give the handle of window-1 to say a function like GetDC you get a device context for window-1 and can now draw on window-1 using a function like TextOut.
If u give handle of window-2 to GetDC you will get device context for window-2 and can output text/anything else you like on window-2.
It is internally managed as a hashtable like structure having (handle,pointer-address) as key-value pairs.
Handles can refer to any Windows object's like GDI or USER etc.
Hope this helps you.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
in case you will close this question, you should not give the points to onkarsingh, because FengYuan and me both gave more info than he, and that before him. You can give the points to FengYuan, that's okay for me...
Regards, Madshi.
P.S: onkarsingh is a bit right, but quite a bit wrong also. In win9x for system/kernel handles there really is a process wide table, which has one object pointer for each handle, but besides also an access field, furthermore the system/kernel object pointers do not change in win9x. The meaning of win9x system handles is to combine an object with a specified access mask. It's different for other handle types. See all the previous comments.
Moondancer
Community Support Moderator @ Experts Exchange

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Please comment in that question to complete this point split award.
Thanks.
Moondancer
Community Support Moderator @ Experts Exchange
Microsoft Development
--
Questions
--
Followers
Top Experts
Most development for the Microsoft platform is done utilizing the technologies supported by the.NET framework. Other development is done using Visual Basic for Applications (VBA) for programs like Access, Excel, Word and Outlook, with PowerShell for scripting, or with SQL for large databases.