The SDK is the software development kit (software development kit). It contains the documentation for Windows software development and the input library and header file of API functions (because the API is in the dynamic link library, these dynamic link libraries are part of the system and therefore do not need to be provided. The input library and header file are required so that you can use API functions in your program ). The early SDK was a separate package, which is now included in Visual C ++ and other development environments. If you have installed VC ++, you can start writing Windows programs. With the development of Windows systems, more and more sdks are available. We only need to grasp the most basic aspects. For other special topics, we will learn more based on our own interests and technical directions.
Don't be intimidated by the first Windows program
If you have already started, your textbooks should be the classic programming windows (Petzold) or a similar book. But no matter which book, you will first face a basic Windows SDK program, which has dozens of lines. Although it is not long, it is much longer than the C version of Hello world. Even worse, it is filled with strange variable types and constant definitions, but we don't need to be scared by it. Let's take a look at what is in it. First, there will be a # include <windows. h>. Well, it's no surprise. It's no different from # inclde <stdio. h>. Then there is a function declaration: lresult callback wndproc (hwnd, uint, wparam, lparam); it's a bit confusing, and several new words come out at once ", in addition, there are two modifiers before the function name, which were not previously encountered. Fortunately, we can also identify this as a function declaration. Next we will look at the winmain function and a bunch of new words. I guess you may have started to get depressed. It is really difficult to read this program once, so it doesn't matter if you don't understand it. You can read the explanation in the book. This article does not require a complete analysis of this program. hfire cannot have Petzold. Here hfire helps you analyze some strange things.
First, the Data Type of windows. Although these data types seem unfamiliar, they are actually defined by the basic data type of C. For example, uint is unsinged int, and pstr is pointer to string. You can guess whether it is char *. Windows also has many system-defined structs, such as wndclass and MSG, which can be understood as much as they are. Windows also has an important concept, handle. You can use a handle to operate windows objects. Hwnd, hinstance, and HDC are all handles.
Let's talk about the structure of the Windows program. Generally, there is a winmain function as the entry point of the program. In winmain, the window class is defined for message loop. A message loop is a common while loop in which messages are received and sent separately. Then, the window function wndproc can be set by name. Retrieve a message using a large switch structure, and write the Message Processing code under each case. The simplest windows SDK program only needs to write these two functions. When your program has been written for a long time, you need to write the specific message processing code into a function so that it can be called when processing the message. You can even use C ++ to write the program. After you are familiar with this structure, you can make full use of it.
Others don't want to talk too much. It is very important to learn the SDK. Don't expect to clarify each line of code at the beginning.
Learning Methods
Of course, it is to write more programs. It is best to write one for each topic. From the first window, text is displayed to graphic display, controls, and dialog boxes, you can understand the connotation of Windows Programming by writing more. When the first part has learned almost the same thing, you can write a program that combines points. Finally, you will find that you can write a long program, and more than 1000 lines are not long, but it is hard to imagine when you learned C at that time. It is also important to have more specialized websites, such as the VC knowledge base (www.vckbase.com) and the VC path (there is a good tutorial, but now there are no things on the website and it is being restored ), in addition, www.csdn.net is also a good place.
Analysis of Several windows programming methods and other
Many beginners often confuse Windows Programming With VC ++. Open the new project of VC ++ and you can see that VC ++ supports many types of projects. Including command line, MFC, and Win32 application, that is, the SDK program. Using VC ++ is not necessarily an SDK program, nor is it necessary to use VC ++ to compile the SDK program. Writing a Windows program is not only an SDK, but also a class library such as MFC and owl, and a quick development tool such as VB and Delphi. Each of these methods has its own usefulness. Using the SDK is undoubtedly the most troublesome. We are not learning the SDK to use it to compile software. Although it can, it mainly aims to have a clear understanding of Windows programming, in this way, you can achieve "self-built gully in the chest" when using MFC ".