1. Handle Concept
A handle is a concept in a Windows program. It is essentially a 4-byte (8 bytes in a 64-bit program) integer that identifies different instances.
Because data is changed in the memory address, Windows introduces the handle concept for memory management.
2. Handle and common pointer
The pointer contains the memory address of the referenced object, and the handle is the reference identifier managed by the system. The identifier can be located on a memory address by the system.
3. Use of handle
A handle is meaningful only when a project is identified. The handle corresponds to one of the project tables. Only Windows itself can directly access this table. Applications can only process different handles through API functions. For example:/* call the globalalloc API to return a handle value. The current hmem is an index value not a physical address, and the application cannot directly access this memory */handle hmem = globalalloc (......); /* The application needs to call the globallock function of the API function to lock the handle to access this memory */void * lpmem = globallock (hmem );
4. Global memory operation functions related to handle usage /* Allocate memory */globalalloc ();/* Lock memory */globallock ();/* unlock memory */globalunlock ();/* release memory */globalfree ();