Windows Programming Note 1

Source: Internet
Author: User

Int winapi winmain (

 

Hinstance,

 

Hinstance hprevinstance,

 

Lpstr lpcmdline,

 

Int nshowcmd

 

);

The winmain function declares that an int value is returned. The winapi identifier is defined in windef. h. The statement is as follows:

# Define winapi _ stdcall

This statement specifies a call convention, including how to generate a mechanical code to place a function call parameter in the stack. Many WINDOWS function calls are declared as winapi.

 

The first parameter of hinstance winmain is called "execution entity handle 」. In Windows programming, a handle is only a number used by an application to identify something. In this case, the handle uniquely identifies the program and needs to be used as a parameter in other Windows function calls. In earlier versions of Windows, when you run the same program multiple times at the same time, you created the program's "multiple instances )」. All implementing entity sharing programs and read-only memory for the same application (usually resources such as menus and dialog box templates ). By checking the hprevinstance parameter, the program can determine whether other execution entities of the program are running. Then it can skip some complicated work and move some data from the preceding execution entity to its own data area.

In 32-bit windows, this concept has been abandoned. The second parameter passed to winmain is always null (defined as 0 ).

 

The third parameter of lpcmdline winmain is the command column used to execute the program. Some Windows applications use it to load files into memory when the program starts.

I just copied so many copies on the first day. I hope I can stick to it later and read this book well.

Source code attachment:

/* -------------------------------------------------------------- <Br/> hellomsg. c -- displays "Hello, Windows 98! "In a message box <br/> (c) Charles Petzold, 1998 <br/> -------------------------------------------------------- */</P> <p> # include <windows. h> </P> <p> int winapi winmain (hinstance, hinstance hprevinstance, <br/> pstr sz1_line, int icmdshow) <br/>{< br/> MessageBox (null, text ("Hello, Windows 98! "), Text (" hellomsg "), 0); </P> <p> return 0; <br/>}< br/>

 

The fourth parameter of nshowcmd winmain indicates the method in which the program is initially displayed, which can be normally or fully filled with the entire screen, or minimized in the work column.

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.