Getting Started with WINAPI

Source: Internet
Author: User
Tags message queue numeric value win32

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.

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.