Windows core Programming 02-Notepad writing code in-depth understanding of cl.exe and Link.exe

Source: Internet
Author: User

Next, write the code in Notepad:

1, build an empty Notepad, typing the following code

" windows.h " int int cmdshow) {    MessageBox (NULL,"helloworld!","Info", MB _abortretryignore| mb_iconinformation);     return 0 ;}

2. Open the cmd window and enter cl.exe/? If there is an error, if there is an error running

D:\Program Files\Microsoft Visual Studio\vc98\bin\vcvars32. BAT

Drive letter to see the installation path of VC 6.0, here can also double-click Cl.exe if the error is missing Mspdb60.dll, go to Baidu next put to the current directory

3. Cut the current directory to the path where Notepad is located CD D:\XXX\XXX\XXX

Rename the Notepad to xxx.c such as hello.c

1, compile:cl.exe/c hello.c will generate a hello.obj file

2, Link:link.exe hello.obj user32.lib will generate a hello.exe

Double-click Hello.exe Pop-up MessageBox

What does the 4,winmain parameter lpCmdLine represent?

Modify the code as follows:

    

" windows.h " int int cmdshow) {    MessageBox (null,lpcmdline,"Info", mb_abortretryignore| mb_iconinformation);     return 0 ;}

Compile, link ....

Double-click Hello.exe ... Well, there's nothing, it's empty, it feels like it's been fooled.

Drag a file to Hello.exe, you see anything? In the MessageBox, show the path of the dragged file to know what the lpCmdLine is, and also know that video files can be dragged to the player to play is how to achieve it?

    

Handle: Now temporarily understood as a handle is used to find memory, absolutely not a pointer

int Winapiwinmain (

HINSTANCE hinstance,//The instance handle of the current program

HINSTANCE hprevinstance,//Current Program Previous instance handle

LPSTR lpcmdliine,//command-line argument string char*

int ncmdshow//window display mode, Maximize, minimize ...

);

int MessageBox (

HWND hwnd,//Parent Window handle, beginning with H can be determined as a handle

LPCTSTR lptext,//The text displayed in the message char*

LPCTSTR lpcaption,//The text displayed in the title bar

UINT utype//button, icon display type in message box

); Returns the button ID of the click

  

To write a window program:

1 Defining the WinMain function

2 defining window processing functions (processing messages)

3 Register window class

4 Creating Windows (creating windows in memory)

5 Display window (draws the window based on the data in memory)

6 message loop (extract/translate/distribute) message

7 Message Processing

Use of resources

Writing a resource's file-.rc resource script file

Writing RC Files-rc.exe

Linking resources to Programs-link.exe

Windows core Programming 02-Notepad writing code in-depth understanding of cl.exe and Link.exe

Related Article

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.