Let's explain in detail belowThe concept and meaning of handles in Yi language
This is a concept in the operating system. Handles are unique integers used by WONDOWS to identify objects created or used by applications. WINDOWS uses various handles to identify applications such as application instances, windows, controls, bitmaps, GDI objects, etc. The WINDOWS handle is a bit like a file handle in C language.
From the definition above, we can see that the handle is an identifier that is used to identify an object or project. It is like our name. Everyone will have one. Different people have different names, but there may also be someone with the same name as you. From the data type, it is just a 16-bit unsigned integer. An application almost always obtains a handle by calling a WINDOWS function, which can then be used by other WINDOWS functions to reference the corresponding object.
If you want to know handles more thoroughly, I can tell you that handles are pointers to pointers. We know that the so-called pointer is a memory address. After the application is started, the objects that make up the program are retained in memory. If we simply understand it, it seems that as long as we know the first address of this memory, we can use this address to access the object at any time. But if you really think so, you're very wrong. We know that Windows is a virtual memory-based operating system. In this system environment, Windows memory manager often moves objects back and forth in memory to meet the memory needs of various applications. An object is moved means its address has changed. If the address always changes like this, where should we find the object?
To solve this problem, the Windows operating system frees up some internal storage addresses for each application to specifically register the address changes of each application object in memory, and this address (the location of the storage unit) itself remains unchanged. After moving the object's location in memory, the Windows memory manager tells the object's new address to save it. In this way, we only need to remember this handle address to indirectly know where the object is in memory. This address is assigned by the system when the object is loaded (Load), and is released to the system when the system is unloaded.
Handle address (stable) → record the address of the object in memory——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Essence: In the WINDOWS program, it is not a physical address to identify a memory block, file, task or dynamic loading module. On the contrary, the WINDOWS API assigns a certain handle to these projects, returns the handle to the application, and then operates through the handle.
However, it must be noted that every time the program is restarted, the system cannot guarantee that the handle assigned to the program will be the original handle, and most of the situations are indeed different. If we think entering the cinema to watch movies is to start and run an application, the system will always assign handles to the application, which is the same as the tickets sold to us by the cinema will always have a different seat.