Simple concept of handle

Source: Internet
Author: User

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 ();

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.