C ++ learning the internal operating principle of Windows program

Source: Internet
Author: User

Learn C ++ and. net is different, it is necessary to understand the internal operating principle of the Windows program, because most of it involves the calls of the operating system, and. net is in. sing on netFrameWork.

What is the relationship between Windows applications, operating systems, and computer hardware? The figure below gives a good explanation.

The Down Arrow ① is the result of the application program processing and output to the output device.

The up arrow ② is the input device and the input to the operating system.

The Down Arrow ③ represents the API. We need to explain what the following API is. An API is an application interface, indicating that an application can notify the operating system to perform a specific action. For example, the operating system can control the sound card, but it does not know when to make a sound, the application needs to tell the operating system what sound to make. This relationship is like a robot capable of walking. However, if people do not tell the robot in which direction it is going, the robot will not walk on its own initiative. Here, robots are operating systems, and people are applications. For programmers, it can be understood that they can call the function library. C ++ programmers use the same operating system. The APIS called in Java are the function libraries provided in jdk. Net programmers are the function libraries provided by. netframework.

The up arrow ④ indicates that the operating system can upload the changes of the input device to the application. If a user clicks the keyboard during a program activity, the operating system can immediately detect the event and know which one key the user presses, the operating system does not decide how to respond to this event. Instead, it transfers the event to the application and the application determines how to respond to the event. Like a driver driving a car and seeing a car in front of him, our neural peripheral (equivalent to the operating system) immediately perceives this incident, and passed to our brain (equivalent to an application), our brain eventually decided how to respond to this event, such as stepping on the brakes and stopping, or a heroic collision (it is an sb practice ). Respond to the event.

How does the Operating System pass perceived events to applications? This is achieved through the Message mechanism. The operating system packs each event into a message struct MSG to pass to the application. For more information, see MSDN.

The MSG structure is defined as follows:
Typedef struct tagMSG {HWND hwnd; UINT message; WPARAM wParam; LPARAM lParam; DWORD time; POINT pt ;}msg; the process is the message response.

Actually, I wrote it here as a. net developer who has been working for three years. I have been touched here. C ++ is like this. net event response mechanism. It is not a message mechanism. Message mechanism is a qualitative leap in the program field. It is also a message mechanism that encapsulates the control of. net programmers too dead, and creates a large number of programmers who can only drag controls. After I learned C ++, I still feel very open .. Net programmers, let's look at C ++ more!

Related Article

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.