Windows common face question--handle

Source: Internet
Author: User
1. What is a handle, please talk about your understanding

A: The handle is actually a long data, which is the unique identity that the operating system assigns to the object when it is generated.
Although Windows is written in C and sinks, it also uses object-oriented thinking. (such as Windows, files, drawing device environment, etc.) they are objects, the data of an object should be hidden, we should only modify the data through the interface, but unlike C + +, the function and data are not packaged together, so there is the concept of a handle to represent an object, Then, when you use a function to manipulate the object, you need to pass in the handle, which acts like the this pointer in C + +. The ultimate goal is to access the object, and a handle represents an open operation for the object. The handle is the key that we go to access the object, which is the index of the object.

2. What are the types of handles?

A: The common handles are:
HWND Window Handle
HINSTANCE current real-column handle
Hcursor cursor Handle
Hfont Font Handle
Hpen Brush Handle
Hbrush Paint Brush Handle
HDC Device Environment handle
HBITMAP Bitmap Handle
Hicon icon Handle
HMENU Menu Handle
hfile file Handle

3. For kernel processes, there is a process table in the process. Are the same handle values stored in process tables in different processes representing the same kernel object?

A: The handle of a kernel object is process-dependent, and for the same object, its handle value is different in different processes, unlike GDI objects, where the handle value of the GDI object is globally valid, and in different processes you can access the same GDI object using the same handle value. In each process object, there is a handle table that is used to log all kernel objects opened by the process, and the value of the handle can be simply considered an index in the handle table, so the handle value of the kernel object is only valid for this process.

4. What is a module and what is the nature of the module handle?

Windows common face question--handle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.