Windows Program Basics

Source: Internet
Author: User

In Windows, the basic unit of a program is not a procedure and a function, but a window. A window is a set of data and a collection of window functions that process the data. If you consider the object-oriented perspective, the window itself is an object. The execution of Windows programs is itself the process of creating, processing, and dying out objects such as Windows. The sending of messages in Windows can be understood as a process of requesting a service from a Window object to another Window object. So. The idea of object-oriented programming is the first choice for Windows programming.

One. Handle

Microsoft has called this example of a data structure that describes things as objects. Although Microsoft has defined these data structures in the Windows system but not exposed them to the user, Windows provides the appropriate service functions in the API to enable the user application to create and obtain such objects, and the user obtains the objects created by the system by calling this function. Because objects created using this method are in kernel memory space, they are called kernel objects. It must be noted, however, that after the user invokes the API function to create the kernel object successfully, the function returns a 4-byte integer temporary number that the Windows operating system compiles for the kernel object. For readability of the program, and depending on the purpose of this number, Windows defines an alias for this integer data variable: "Handle (Handle)".

A handle represents a kernel object.

The reason is called the handle type, because it is similar to the function of the tool holder, the pot handle in the life, the meaning is that when the user obtains the handle, then obtains the "handle" which installs on the kernel object, can operate without direct contact with this object. From the point of view of use, a handle is similar to a pointer's function, pointing to an object or storage area, but the pointer is an address, and the handle is just an integer form number and cannot participate in the operation like a pointer.

1.HINSTANCE handle

HINSTANCE Handle--application instance handle.

In the eyes of the operating system, an application is a code-running process and an object that it is responsible for running and managing. Therefore, the operating system must establish a struct variable for the program before the program runs so that it can record the program's running progress, status, memory consumption, and data about the use of files and peripherals, and then manage the operation of the program based on the data. The Windows operating system controls the operation of a program through this data structure variable associated with the program code. This kernel object in Windows that represents a program's running process, called a Process object or process, is also called a "process control block." In Windows, this type of Process control block is hinstance.

The hinstance type handle is considered a new data type for Windows definition-the program type, and its object is equivalent to a variable of a program type, which represents a running program, and every time Windows runs a program it assigns the pointer to that variable. The program can use this variable to manipulate a program. Note: If the user launches the Word application two times, there are two application instance handles for word in the system.

Windows Program Basics

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.