Home >Common Problem >What is the handle?
Handle has many meanings: 1. In programming, it refers to a special smart pointer; 2. In Windows programming, it is the only object used by Windows to identify objects created or used by the application. Integers, Windows uses a variety of handles to identify objects such as application instances, windows, controls, bitmaps, GDI objects, and so on.
Handle, there are two interpretations
First An explanation: The handle is a special smart pointer. When an application wants to reference memory blocks or objects managed by other systems (such as databases and operating systems), handles are used.
The second explanation: The basis of the entire Windows programming.
A handle is a unique integer used by Windows to identify objects created or used by applications. WINDOWS uses a variety of handles to identify applications such as application instances, windows, controls, bitmaps, GDI objects, etc. .
A handle refers to a unique integer value used, that is, a 4-byte (8-byte in 64-bit program) long value to identify different objects in the application and different objects of the same type. Instances such as a window, button, icon, scroll bar, output device, control or file, etc. The application can access the information of the corresponding object through the handle, but the handle is not a pointer, and the program cannot use the handle to directly read the information in the file. If the handle is not in the I/O file, it is useless. A handle is a unique integer that Windows uses to identify objects created or used in applications. Windows uses handles extensively to identify objects.
The reason why Windows needs to set up handles is fundamentally due to the problem of memory management mechanism, that is, virtual address. In short, the address of the data needs to be changed. After the change, someone needs to record and manage the change, so the system uses a handle to record the change of the data address. In programming, a handle is a special smart pointer. When an application wants to reference memory blocks or objects managed by other systems (such as databases and operating systems), handles are used.
Note:
Handles are a very important concept in Windows programming. In Windows programs, physical addresses are not used to identify a memory block, file, task or dynamically loaded module. . Instead, the Windows API assigns specific handles to these items and returns the handles to the application, which then performs operations on them.
It should be understood that a handle is an identifier, which is used to identify an object or project. From the data type point of view, it is just a 16-bit unsigned integer. Applications almost always obtain a handle by calling a Windows function, which can then be used by other Windows functions to reference the corresponding object. A large number of handles are used in Windows programming.
The above is the detailed content of What is the handle?. For more information, please follow other related articles on the PHP Chinese website!