Read windows programming (2)

Source: Internet
Author: User

 

"In short, Unicode is extended from the ASCII character set. In strict ASCII, each character is represented by 7 characters, or each character is commonly used on the computer with 8-Bit Width, while Unicode uses a full 16-bit character set. This enables Unicode to represent characters, hieroglyphics, and other symbols that may be used for computer communication in all writing languages in the world ."

"Unicode affects every part of the computer industry, but it may have the greatest impact on operating systems and programming languages. From this perspective, we are on the road. Windows NT supports Unicode from the underlying level (unfortunately, Windows 98 only supports Unicode in a small part )."

"The ANSI-bound C programming language supports Unicode by providing support for wide character sets ."

"DBCS starts from code 256, just like ASCII. Like any well-performing code page, the first 128 codes were ASCII. However, some of the higher 128 codes always follow the second byte. These two bytes together (called the first byte and the following byte) define a character, usually a complex pictogram ."

"It is important to understand the differences between Unicode and DBCS. Unicode (especially in the C programming language environment) "wide character set 」. 「 Every character in Unicode is a 16-Bit Width, not an 8-Bit Width .」 In Unicode, there is no meaning to simply use an 8-bit value. In contrast, we still PROCESS 8-bit values in the double-byte character set. Some bytes define characters, while some bytes display the need to define a character together with another byte ."

"Unicode is also flawed. The first and most important point is that every string in the program occupies twice the storage space. In addition, you will find that the function in the Linked Library is larger than the common function during the wide character execution period. For this reason, you may want to create two versions of programs-one for processing ASCII strings and the other for processing Unicode strings. The best solution is to maintain a single source code file that can be compiled by ASCII and compiled by Unicode ."

"Windows NT supports Unicode from the underlying layer. This means that Windows NT uses a string consisting of 16 characters. Because 16-bit strings are not used in many other parts of the world, Windows NT must often convert strings within the operating system. Windows NT can execute programs that are compiled in combination with ASCII, Unicode, or ASCII and Unicode. That is, Windows NT supports different API function calls. These functions accept 8-bit or 16-bit strings ."

 

/*---------------------------------------------------------------------------
Scrnsize. c -- displays screen size in a message box
(C) Charles Petzold, 1998
----------------------------------------------------------------------------*/
# Include <windows. h>
# Include <tchar. h>
# Include <stdio. h>

Int cdecl messageboxprintf (tchar * szcaption, tchar * szformat ,...)
{
Tchar szbuffer [1024];
Va_list parglist;

// The va_start macro (defined in stdarg. h) is usually equivalent:
// Parglist = (char *) & szformat + sizeof (szformat );

Va_start (parglist, szformat );

// The last argument to wvsprintf points to the arguments

_ Vsntprintf (szbuffer, sizeof (szbuffer)/sizeof (tchar ),
Szformat, parglist );

// The va_end macro just zeroes out parglist for no good reason
Va_end (parglist );
Return MessageBox (null, szbuffer, szcaption, 0 );
}

Int winapi winmain (hinstance, hinstance hprevinstance,
Pstr szcmdline, int icmdshow)
{
Int cxscreen, cyscreen;
Cxscreen = getsystemmetrics (sm_cxscreen );
Cyscreen = getsystemmetrics (sm_cyscreen );

Messageboxprintf (text ("scrnsize "),
Text ("the screen is % I pixels wide by % I pixels High."), cxscreen, cyscreen );
Return 0;
}

Based on the information obtained from the getsystemmetrics function, the program displays the video width and height in units of an image. Getsystemmetrics is a function that can be used to obtain the size information of different objects in windows.

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.