Win32 Windows Programming Three

Source: Internet
Author: User

I. NMAKE and Makefile

1.1 NMAKE-command interpreter, complete the compilation of the project according to the script defined in the makefile file

1.2 Makefile-Define scripting languages such as compilation, connection, etc.

1.3 The use of Makefile files

1.3.1 Basic Grammar Rules

Window.exe:window.obj//Dependent rows

cl.exe window.c/c//Command line

Link.exe Window.obj User32.lib

The Window.exe dependency is window.obj, and if Window.obj is rewritten window.exe will regenerate

Use timestamp (time stamp) to determine if the program needs to recompile the connection, to recompile the connection

If the file modification last time differs from the timestamp, the link will be recompiled.

1.3.2 Execution Process

1 NMAKE first finds the first dependent row and builds a dependency tree based on the relationship between dependent rows. For example:

A:b

B:c

C:d

NMAKE will build the corresponding dependency tree,

A

|-b

|-c

|-d

2 after the tree is built, NMAKE executes the command line of D first, then executes the parent node's command line,

3 after the command line of a has finished executing, exit NMAKE

4 If you need to execute a specified dependent row, you need to increase the name of the dependent row when you execute NMAKE

1.4 Use

1.4.1 Namke specified file

1.4.2 using the default file name
If make file name uses makefile directly using the NMAKE command

Second, character encoding

Messagebox:messageboxa MessageBoxW

2.1 History of the coding

2.1.1 ASCII 0~127 7-bit representation

2.1.2 ASCII Extension Code 8-bit representation

Code page: Toggle the corresponding character by code page

2.1.3 Double-byte character set DBCS

Use one or two bytes to represent characters

2.1.4 Unicode

Use all 2 bytes to represent a character

Memory/hard disk and other resources occupy large

2.2 C Language and encoding

2.2.1 Single-byte characters and strings

char c = ' A ';

char * pc = "ABCD";

2.2.2 Wide-byte characters

wchar_t ctext = ' A ';

Wchar_t*psztext = L "ABCD";

2.2.3 Correlation function

A function of a single-byte character that corresponds to a function with a wide byte.

Strlen Wcslen Mbslen

printf wprintf

2.2.4 TCHAR

In order to easily support Unicode and multibyte characters in the program, use TCHAR to define characters and strings

A more _UNICODE macro switch compiles TCHAR into different character types
#define Unicode

#ifndef Unicode
typedef char TCHAR
#define __T (x) x
#else
typedef wchar_t TCHAR
#define __T (x) l# #x
#endif

Need to add TCHAR.H header file support, use _UNICODE macro Kaifu ann to compile

How to define:

tchar* PszText = __t ("ABCDEF");

2.2.5 Unicode for console printing

Writeconsole

2.3 Win32 Program and coding

Definition of 2.3.1 Win32 API

Each API has a different version of multibyte and Unicode

MessageBox

MessageBoxA Multi-byte

MessageBoxW Unicode characters

2.3.2 Character Conversion

MultiByteToWideChar

WideCharToMultiByte

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.