C++ learning journey how Windows programs work internally

  • 2020-04-01 21:26:40
  • OfStack

Learning C++ is different from. Net, it is important to understand the internal operation of the Windows program, because it involves most of the operating system calls, and.

        The diagram below illustrates the interrelationship between Windows applications, operating systems, and computer hardware.

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201211/2012110121275551.jpg ">

      The down arrow is the result of the application running judgment processing, output to the output device.

      Up arrow is the input device, input into the operating system.

      The down arrow represents the API, and we want to explain what the following API is. The API is the application programming interface,   Means that the application can tell the operating system to perform a specific action, such as the operating system can control the sound card to make a sound, but it does not know when to make what sound, the application needs to tell the operating system what sound to make. The relationship is like having a robot that can walk, but it won't walk if people don't tell it which way to go. Robots are operating systems and people are applications. For programmers, this means you can call libraries, and C++ programmers use the same operating system. The API called in Java is a library of functions provided in the JDK. Net programmers are function libraries provided by. Net framework.

      The arrow () up indicates that the operating system is able to transmit changes to the input device to the application. Such as user when a program activities according to knocked at the keyboard, the operating system can sense immediately to the event, and be able to know what the user presses a key, the operating system does not react to this event how to decision, but also pass the event to the application, by the application to decide how to react to this event. Like driving a driver saw in front have a car, our nerve endings (operating system) immediately perceive this event, and passed to our brains (application), our brain finally decide how to react to the event, such as brake, stop, or brave into it (is a sb). React to events.

      How does the operating system pass aware events to the application? This is done through the Message mechanism. The operating system passes each event to the application as a structure called message MSG, see MSDN.

MSG structure is defined as follows:
Typedef struct tagMSG {HWND HWND; UINT message; WPARAM WPARAM. LPARAM LPARAM; DWORD time; POINT pt; } MSG. Is the message response.  

      Actually, let me write it here, as a.net developer for 3 years. I'm impressed that C++ is such a. Net event response mechanism. It's a message mechanism. Message mechanism, is a big qualitative leap in the programming world, and this is the message mechanism, the.net programmer control package is too dead, also created a large number of only drag control programmers. I learned C++ or really have a kind of open - door feeling. Net programmer, still read more C++!


Related articles: