Don't be surprised, although we have a lot of "WYSIWYG" programming to develop many user-friendly applications, these visual programming environments provide a lot of class libraries and controls, but while developers enjoy the convenience, their hands and feet have been unknowingly limited, There are a lot of things that go deep inside windows and they can't be done, why? Because the class library you are using is not supported.
In fact, these class libraries and controls are based on the Windows API, the API is applicationprogramming Interface-the abbreviation for the application programming interface, which is called not only for the application, but also as part of a window, These API functions are also invoked by Windows itself. To understand how to use the API, you must understand some of the running mechanisms of Windows.
Simply put, Windows is an event-driven preemptive multitasking operating system. Event-driven is relative to the process driver, it changed the sequential execution of the original file; Since Windows is a multitasking system, it must be able to handle multiple events at the same time, and the system generates a message queue for the application, where the message is posted and sent, and the application simply extracts the message from its message queue. And then you can do it.
Now, I will use the most basic sample program Hellowin to illustrate the WIN32 API's operating mechanism first, a program must have access point, Win32 app's entry point function name is WinMain, its prototype is as follows int apientry WinMain ( HInstance hinstance, hinstance hprevinstance, LPSTR lpcmdline,int-nCmdShow) hinstance is called "instance handle", which is a numeric value, When the program is running under Windows, it is used to uniquely label the program, although the user may run multiple "instances" of the same program at the same time, and we can see that each instance has a different hinstance value.