Cui (console) Programs and (GUI) programs for Windows Applications

Source: Internet
Author: User

Cui is the console uers interface and GUI is the graphical user interface. As the name suggests, it is a console-based interface and a window-based interface. The so-called console is actually a text, so the console Program is also a text-based application. Speaking of applications, we have to say that a process, an application instance (that is, a running application) is a process. The so-called process is actually an empty shelf, it is composed of a kernel object that records the process and an address space that stores all Code and data and dynamic memory allocation in executable files. With this information, the operating system can effectively manage processes. With this address space, the operating system can start threads in the process. Speaking of threads, threads are actually the core of the real code execution, while processes only provide a breeding environment, and processes are inert. When a process starts, the first thread must be started. This thread is called the main thread. If you want to, the main thread will start level-1, level-2, and multi-level sub-threads. Similarly, when all threads in a process exit, the process will end its own life. With this, we can discuss the differences between Cui and GUI.

As we all know, Windows applications require an entry function, Cui is main, and GUI is winmain. It is precisely because of this different entry that CuI and GUI are differentiated. When talking about the portal, we should have such a question: "What was the portal before ?" In fact, before entering the portal, the first thing to do is to execute the operating system's loading program. This loader checks the file header of the executable file image to link the appropriate entry function. At the same time, make a clear distinction between Cui and Gui: The Cui program loader automatically ensures that there is an available text console, and the GUI program simply loads it. That is to say, what kind of application you want to implement is the link information (which can be specified in linker-> subsyem ). It should be noted that, after the connector instructions, the operating system has called the entry function, but you never thought of it. At this time, your main or winmain is still not called. In fact, at this time, the connector indicates the startup function in the C/C ++ Runtime library called by the operating system. Just now, the application has the Cui and GUI points. Likewise, in the C/C ++ Runtime Library, there are two versions of the startup function, winmaincrtstartup
And maincrtstartup (in fact, there are four, and the other two are Unicode. These two are ANSI. The truth is still, so we will not repeat them here ),

These two functions are the real Fuse. They will set some columns:

1. Get the pointer of the command line parameter of the process and the pointer of the process environment variable;

2. initialize the global variables of the C/C ++ Runtime Library. (This is why _ osver can be used as long as stdlib is included in your code)

3. initialize the memory allocation function (malloc, calloc)

4. Call the constructors of all global and static C ++ class objects.

5. Enter the user's portal. (Cui: Main, Gui: winmain)

Let's take a look at the summary of Windows core programming and learn more about the ins and outs of Windows applications. Share to all!

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.