Chapter III - Windows program
I don't know how to write this chapter, huh, huh ~~
After all, Win32 is a very deepest system. Currently, I can't always say that I have said three four, but since I want to write to those who introduce the first stage, I don't write to the programming design. Old birds, so I also made not afraid that the name is called "Windows program" instead of "Windows program" instead of "Windows program design", I just talk about the principle of Windows program operations:
Why is Windows called Windows, I believe that all those friends who have used it can understand that the window on the desktop is the origin of its name. That is, the emergence of this one window makes the computer's use of simplicity. Friends who have come into contact with the computer have known DOS. If I don't know, I will ask the Decryption tool download version of the moderator old brother, let him explain the black window that you still remember the dark window, no I have seen my brothers can find it in the start menu. DOS performs a corresponding operation by a series of commands, such as entering a directory, deleting a directory, etc., etc. That way of working is called a command prompt method, that is, the command line.
Nowadays, people who don't understand the computer are still old, say that they want to learn computers, they must pass English. (That is, how much is it just how much I want to learn some basic operations may be the reason for DOS.
Later, with hardware support and technology improvement, of course, there is also a more convenient service and people, slowly has the so-called view operating system, and since then, you don't have to remember the big directive. And in operation, there is also a great improvement, it can be said that the operating system has developed to today's children, the operation is simple enough, go to see the children who are snot in the Internet cafes ...
Of course, just like the DOS in that year, today's Windows still occupies most user bases like this year.
(Off-site: A viewer throws an endotone, you are Tang Yan, so much nonsense)
Immediately transfer to the topic, the reason why Windows is easy to use, in addition to the commands that don't have a back N, one reason is because it itself provides a large number of standard Windows GUI functions. So for the user, facing the same set of standard windows, the operation of these windows is the same, so there is no need to re-learn when using different applications. It is not necessary to install a new program in DOS, you will see your help, see the instructions.
The Windows GUI function is only a small part of Microsoft provides a small part of the API (Application Programming Interface Application Programming Interface) of the program developer. Windows API is a large group of powerful functions that are stationed in Windows for people to call. Most of these functions are included in several dynamic link libraries (DLLs), such as kernel32.dll, user32.dll, and gdi32.dll. The function in kernel32.dll works primarily to process memory management and process schedule; the function in user32.dll mainly controls the user interface; the function in GDI32.DLL is responsible for graphics operations, etc.
You may have fewer hear that the API function is, if you are not very clear, I try to give you a clear point.
I don't know if you have thought about it, how is the one window in Windows? Oh, you may use VB, Delphi to compile the program, how did you have the windows in the program you want to write? It is the control of the control. Pour ... huh, I believe that when you first learn VB or Delphi, you must praise the visual programming environment, is it convenient than VC ? Why don't you spend a lot of useless time for the interface interface of the generator, and so on. (Top of the next Northeast Ministry of Migrant Workers: Kid, you find a lot, I don't talk about it)
It's just that I just want to tell you, all the procedures under Windows you use by calling another Windows API to perform the task, no API, your program can't do anything. Friends who use VB, Delphi, and MFC may say that I didn't call any API at all! In fact, these APIs are automatically converted by the development environment you have. For example, if you use Delphi to create a program, don't move directly, press F9 directly to run it, is there a blank form? This is a standard Windows program, which has all features of the Windows program, such as maximizing buttons, minimizing buttons, shutting down buttons ... You can move it through your mouse.
But if you want to write such a program with VC or Masm32, then you have two ways, in VC , you can use MFC or directly call the API, and in Masm32, you only call the API. The so-called direct calling API means that all operations are done through the most primitive API. By calling the API to generate such a program, you must first register window classes (unless you use Windows predefined window classes, such as MessageBox or Dialog box); then generate windows; then display window at desktop (unless you don't want to display immediately It); then refresh the window customer area;
Trouble, if you want to really let this program run normally, add the following steps:
1. You have to get the handle of your application. 2. After the form is displayed, enter the cycle of unlimited acquisition window messages. 3. If there is a message reaches, processing the window callback function responsible for the window. 4. If the user turns off the window, the exit process is performed.
The above steps need to be called to complete the corresponding API. For example, get the handle of the program with the getModuleHandle registration window class with registerclass or registerclassex; after registration, use the CREATEWINDOWEX function to generate the corresponding window, and then use ShowWindow to display it, and then use UpdateWindow to update the customer area, etc. Wait. These are not counting, if you really call the API to write a slightly big program, you will find that what is not a pleasant thing.
These, just a small small small small small small small .... Part, this only, the real API has hundreds of thousands, including the operations of all aspects of the system. No API, your program can't do anything. For example, there is an edit control in your program. You should call the Text Control in VB. You want to put the user into a variable in the information inside, then Delphi can be implemented with str: = Edit1.Text. The VB should be str = text1.text; but if you use the API, you want to get the text content in the Edit input box, you want to call getDlgitemint (the value entered in Edit is used) getdlgitemtext, getdlgitemtexta (enter in Edit) Value is used as a string. And I am saying the VB, Delphi gets the method of the content entered in the edit box, eventually automatically performs corresponding conversions by the compiler when compiling into executable files. As long as you understand one thing, it is the procedure you use, which is not all calling a variety of API functions in the system. In fact, the API in Windows is equivalent to the system function calls in the DOS system, and interrupt 21. However, in quantity and function, the DOS system function call is not.
If you still don't understand, then I don't blame you, maybe I am unclear, so, still give you a book written by older. Force "Windows programming", you will have increased inner strength after you have seen it, then what you know is not only API.
In fact, I said that I have been teach you to program, so there is no need to say so much about the principle of Windows programs, I want you to know the operational mechanism of Windows programs. When you use the debugger, ask what is the API. (Everyone (very angry) rushed to the stage: "Pull down PK! Take us!")
(I came to the stage again, the lens tangential side, I will come close-up. I only see that there are several sizes of wounds above the wounds may have some important places I have not mentioned. Welcome to correct. If you don't understand anything, please welcome your questions. As long as you don't have too much, for example, "Can you put all the APIs to let me go back to back?"
Attach a few commonly used API functions. I believe that you will have a probably understanding of the API.
MessageBox displays a message dialog
MessageBoxEx displays a message dialog
MessageBoxIndirect displays a certain information dialog
(These three can be used to interrupt those error tips, for example, your registration code is incorrect, the program may prompt you in these functions)
Getdlgitemint gets specified input box integer values
GetdlgiteMtext to specify the input box to enter the string
GetdlgitemTexta has to specify the input box to enter strings
(Software can use these three registration code entered by the user)
GetLocalTime gets current local time
GetSystemTime gets current system time
(Software can use these two to determine if the software has expired)
RegQueryValuea Gets the set value of an item
RegQueryValueexa Gets the settings of an item
RegSetValuea Sets the value of the specified item or child
RegSetValueExa Set the value of the specified item
(If the software is stored in registration information, then these may be useful)
What is mentioned above, just a few usual, more common, more, see the previous tutorial or Windows Developer Manual. Finally, we have to introduce a weight level function, you may not know what the API is, but you must know its name as long as you use the debugger. You can not know who the current president of the United States, but you must know this function. Although I know that the current US president is Powell but I also know who this function is.
It is ---- Wu Mengda! (Director: Ng) Re-say. It is hmemcpy.
What is this function do?
It is a very simple function. Only one very basic task is completed, that is, copy the data from one place to another. The application itself does not call it, the reason is very simple, it is very low (compilation: Who dares to say to me?). But most of the API functions call it very often. So, it is also called universal function. Usually you may not know if there is such something, but the assertion is very tube. But now 2K with XP, there is no such function, and the corresponding thing is a function called Memcpy, although the function is the same, but basically is already a wasteman, you can't break anything with Memcpy. So, such a good function can only be used in 98. This is like the President of the United States, so that it can only make it eight years, don't say it. I can kick him next year.
I don't say anything else, this chapter you know what the API is going.
If you have any improper place or have any questions, and if you want civilization, please reply. If you want to be a little bit, take the egg to your monitor.