字体、语言相关的API函数原型:( G: ~/ m( Y4 d& r4 f( |
0 [% S* Q- i0 icreateFont 用指定的属性创建一种逻辑字体 1 V; d) ~ T- a
createFontIndirect 用指定的属性创建一种逻辑字体 3 e$ ?6 ~$ v: z' D
GetStockObject 取得一个固有对象(笔、刷子、字体等)" ?' Q7 q, j0 A& m4 N
; K% F5 r- O( ]# m& pGetACP 检取ANSI系统代码页的标识符
K3 P1 p1 e5 u( I! d+ c4 SGetOEMCP 检取系统的OEM代码页标识符
/ U% ?' e2 m& r |( M. C1 VGetTextExtentPoint 判断一个字串的大小(范围)(用于限制输入)! G" m- I5 P% c. z# g, x
EnumFontFamilies 列举指定设备可用的字体
' U2 a" t1 R1 U O, O' ^EnumFontFamiliesEx 列举指定设备可用的字体 # t9 U! k+ h0 [3 [* T( X1 M$ l
EnumFonts 列举指定设备可用的字体5 { n% U5 S; N3 Z3 l/ W% K5 Q
GetSystemDefaultLangID 取得系统的默认语言ID : o0 s9 P9 x+ O$ e% `* P6 [! R* B8 a
GetUserDefaultLangID 为当前用户取得默认语言ID
. q. }8 r7 {$ ]6 ~ B, UGetStringTypeA 获取ANSI字符串类型 ,返回指定字符串的字符类型信息7 R' Z5 w5 p$ h
GetStringTypeW 返回一个Unicode串的字符类型信息: I% v/ h" y0 e+ o
GetSystemDefaultLangID 检取系统缺省语言标识符8 ^6 A2 ~/ H* B* A% ~6 H4 q& H
WideCharToMultiByte 把一个宽字符串映射为一个新字符串4 K. {, G- [5 G( E+ h; D
- h& l/ x! o1 p
=====================================================================
/ X1 W2 c0 |- G4 G1 W3 z. ^/ [. V H# [- [
HFONT CreateFont(# \/ Q% c5 _: M5 I, ^4 ^
- ?( u5 o* L6 I( ?$ H
int nHeight, // logical height of font $ {$ v# K6 e) f- I! O! c0 ^' k: p& }. b
int nWidth, // logical average character width
' G1 y3 D6 y! x& X# Jint nEscapement, // angle of escapement . ?6 @' ? g0 ~, I; [4 D
int nOrientation, // base-line orientation angle
4 Q+ Q% J( r' f/ _( mint fnWeight, // font weight 2 J J1 G# }5 |. T$ J
DWORD fdwItalic, // italic attribute flag
; q8 v+ H7 F% e1 Q4 [* TDWORD fdwUnderline, // underline attribute flag 6 x! @) n6 A* G0 S; B- c; y- O
DWORD fdwStrikeOut, // strikeout attribute flag B0 q- \2 j/ Y2 c9 l* `, F
DWORD fdwCharSet, // character set identifier 6 N8 K# [, N6 g" h
DWORD fdwOutputPrecision, // output precision
% y. |. ?, h0 c) f, i, ~9 }DWORD fdwClipPrecision, // clipping precision
: u) W; j# X4 E+ v: w5 eDWORD fdwQuality, // output quality ! l6 O9 l/ l* q* \* n* `& b
DWORD fdwPitchAndFamily, // pitch and family
. n* A& |1 G4 KLPCTSTR lpszFace // pointer to typeface name string
. C3 p, ]6 m2 V; z7 E8 p2 }5 ~4 @);
9 K. v( L8 E: G0 m, z7 j; L4 u- j9 }: z
==========================================================================5 X3 ^& R2 H1 }# M4 s6 p1 N
HFONT CreateFontIndirect(# y, M' f- T3 x5 G4 U' \
* F3 E. [3 p2 Z
CONST LOGFONT *lplf // pointer to logical font structure . Y4 T2 }# l) n5 X+ s, D( T
);
1 O, ]. W; ? w, L! M1 l7 f& V
: I" u6 \- \% e! Q5 V' W% e0 i==========================================================================
6 G8 E( }8 f7 P" V, r2 o) [6 h* PHGDIOBJ GetStockObject(* M" ]1 T! \* a
4 s! q. p; o jint fnObject // type of stock object 2 `4 D0 n! C5 t7 n
);
) L. z. i/ x2 G( ]" D. j
. W! X$ G/ _/ l" d8 k+ J6 G
5 k) E+ \, F( \7 l/ J; ]fnObject
$ l, U3 v: |, s8 f* \ Q" j. mSpecifies the type of stock object. This parameter can be any one of the following values:
! v: q- n5 B* s( J o# x+ YValue . b) a: F; O9 Q9 ~/ z# A
4.BLACK_BRUSH Black brush.& j7 `5 K6 R! ~
3.DKGRAY_BRUSH Dark gray brush.
, m H) e1 z! k. j+ z2.GRAY_BRUSH Gray brush.8 f1 g% a9 m3 L* S8 U
5.HOLLOW_BRUSH Hollow brush (equivalent to NULL_BRUSH).# b; B" X: l* F
1.LTGRAY_BRUSH Light gray brush.
2 s3 z" I( g) k* q- {5.NULL_BRUSH Null brush (equivalent to HOLLOW_BRUSH).
3 W/ t$ m" n8 L7 }0.WHITE_BRUSH White brush.: \' ]& C, c; d9 {* R. G% I# U, P7 c
7.BLACK_PEN Black pen." r& h+ q3 f* F+ B5 r* \" N" b
8.NULL_PEN Null pen.
9 v: M3 p7 {% k8 f6 @* V8 @6.WHITE_PEN White pen.# _; g; b+ Q4 W; u8 i+ [2 J* h! D# }
11.(0B)ANSI_FIXED_FONT Windows fixed-pitch (monospace) system font.
0 S/ q, K0 S& N5 ?$ ~5 V8 C4 z12.(0C)ANSI_VAR_FONT Windows variable-pitch (proportional space) system font.6 r2 Q9 a% Y: H$ \$ r9 r/ w# U
14.(0E)DEVICE_DEFAULT_FONT Windows NT only: Device-dependent font.$ ~; L. |4 |* ^2 P. w7 L/ C$ C( h
17.(11)DEFAULT_GUI_FONT Windows 95 only: Default font for user interface objects such as menus and dialog boxes.(一般选这种)
" Z% Q( [0 l4 t- A6 @10.(0A)OEM_FIXED_FONT Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font.( h- ?; ~. J$ A: u: L1 |8 j) S" N% s
13.(0D)SYSTEM_FONT System font. By default, Windows uses the system font to draw menus, dialog box controls, and text. In Windows versions 3.0 and later, the system font is a proportionally spaced font; earlier versions of Windows used a monospace system font.
! n' i7 C4 l# L! t* k2 }' T16.(10)SYSTEM_FIXED_FONT Fixed-pitch (monospace) system font used in Windows versions earlier than 3.0. This stock object is provided for compatibility with earlier versions of Windows.& ]0 @) W- O ]+ k: Z2 E# q$ F
15.DEFAULT_PALETTE Default palette. This palette consists of the static colors in the system palette.5 I5 ^, d; r( ?. h6 X% }
If the function succeeds, the return value identifies the logical object requested.% u4 Q- P" l9 v, D1 ^
If the function fails, the return value is NULL. 2 x% d2 c6 G; k. W
================================================================================= }- z S. L a" a# g$ z% U: ^% J
The GetACP function retrieves the current ANSI code-page identifier for the system.
! k3 Y3 j; N0 J. E# @UINT GetACP(VOID): p' x! J& n: Z
; N6 @3 v8 S- v# }! z
Parameters
: W9 b# i5 I( J3 X( S8 A( jThis function has no parameters. % J+ f- Z+ v, }7 o' j# U
Return Values# h/ h& ~7 ~+ Z. n
If the function succeeds, the return value is the current ANSI code-page identifier for the system, or a default identifier if no code page is current.
4 Y/ p. {# X5 d$ ^3 dRemarks6 R) K5 A4 S8 h0 P" V, k
Following are the ANSI code-page identifiers:
5 J; ^" ]+ N9 [8 R6 FIdentifier Meaning
/ }# b1 ^5 u- l: K874 Thai( ?/ D' `$ w( z- E
932 Japan; X6 M& Z/ \/ j
936 Chinese (PRC, Singapore)! L" W( W7 y: D5 Q+ N
949 Korean ?# T; m9 S/ p
950 Chinese (Taiwan, Hong Kong)
1 M; t2 R% }7 {" }! {/ {1200 Unicode (BMP of ISO 10646)
- a0 u' k ^ A2 s/ {1250 Windows 3.1 Eastern European
9 @( t8 n, @) ~4 H1251 Windows 3.1 Cyrillic8 g2 q$ V9 \! J0 q6 s$ ?
1252 Windows 3.1 Latin 1 (US, Western Europe)9 V, Y, e0 u- f& n
1253 Windows 3.1 Greek" k. C8 J3 ?" y8 k6 d
1254 Windows 3.1 Turkish
* K2 i3 |$ G, W9 ^1255 Hebrew' Y7 m( Q7 ]( r
1256 Arabic
9 @; D6 A( | o4 P. G1257 Baltic
% B A1 ^- Z# X! ^" \% l" M=============================================================================1 h; a- s9 B. |. H5 p' ~0 A
The GetOEMCP function retrieves the current OEM code-page identifier for the system. (OEM stands for original equipment manufacturer.) # l% A& N" \9 |$ u# H4 o
$ ~3 }- O! ?% T' _) R! a% J: q
UINT GetOEMCP(VOID); E" H0 L3 g6 N4 T9 q, g/ K0 |
& }! D- E: k7 x0 s6 o h1 B6 ]9 ]4 z, i% Z2 X
Parameters1 W/ g. a0 u7 h T9 i
( @4 y( f1 U9 U a6 B! L! F
This function has no parameters.
) Z7 i3 e) f9 o0 p2 `8 N) o
* A. p9 ~% k$ E/ K! J9 WReturn Values
; O+ Z6 ]! Z" ?5 e5 @9 h: Q, |, \1 }4 w6 |* S6 F* t
If the function succeeds, the return value is the current OEM code-page identifier for the system or a default identifier if no code page is current.
: Z1 F+ t W6 ^, f6 b
1 o1 b' T- Z/ d* C6 E& i# Q, URemarks
5 G. O0 Y# x( M ?$ O
3 m4 f; q6 n: R# I5 q4 JFollowing are the OEM code-page identifiers: ; c& {! Z( y; N, Q) w2 Y( A
& x# P6 z4 h+ q( jIdentifier Meaning1 f+ d/ Z3 {) u2 c$ n
437 MS-DOS United States
3 {: @+ c! {4 e4 l/ s/ A `708 Arabic (ASMO 708)* ~+ n6 I0 I0 o# P% q4 l& C$ l) }
709 Arabic (ASMO 449+, BCON V4)
# W T3 ^3 ]/ U' f7 U# s! C+ Q710 Arabic (Transparent Arabic)9 j6 q: N1 `+ j: J" @/ ~8 J
720 Arabic (Transparent ASMO), m' X! ? {2 _$ k3 t2 ?8 r$ [0 A
737 Greek (formerly 437G)
A& {. C+ }2 P8 @* p2 P& _% m: P: x775 Baltic
0 j; S" h0 C7 T5 j3 {3 m9 V850 MS-DOS Multilingual (Latin I)
( G/ d5 q4 {5 A- |" a$ W852 MS-DOS Slavic (Latin II)8 ~$ B# O: S% b' O3 @' J0 s
855 IBM Cyrillic (primarily Russian)
B, F- r' d" t2 r. s1 w* l a1 F857 IBM Turkish. g1 _0 @$ \) X, R; \! n
860 MS-DOS Portuguese# S8 D; G3 F# I" I/ c- ], [0 F* x1 O
861 MS-DOS Icelandic
3 A' L5 _/ @5 [, }- B862 Hebrew% w$ I0 |. G; w) s) e3 i' z0 i' Y2 r& m
863 MS-DOS Canadian-French7 @# b' Q+ l6 x0 w2 \& l& P$ N
864 Arabic: x/ v8 O2 A7 ]
865 MS-DOS Nordic
. `' m9 h$ E8 Q o# X866 MS-DOS Russian (former USSR)- }/ W& Q( ~8 d' y6 t& f4 N# n# [
869 IBM Modern Greek8 W+ Y& r( A3 p
874 Thai P! K* ]' v+ A
932 Japan
}' G v) w. ~8 O7 i: @2 A- q! f936 Chinese (PRC, Singapore)
& i; W$ _5 A! v. t' A V* ?949 Korean
$ N5 L3 y8 g& w% }! _950 Chinese (Taiwan, Hong Kong) 4 J# R4 l5 K4 @ E+ f' _: t
1361 Korean (Johab)
/ S2 s2 r8 o- M! I===============================================================================
% d3 Q& K- Y/ |, C/ MBOOL GetTextExtentPoint(; u% z9 p1 D3 G- J
, j* s& N; |5 [! k$ g5 l( j7 KHDC hdc, // handle of device context
1 h7 Z+ J2 Z$ C c2 OLPCTSTR lpString, // address of text string 8 t1 ^3 V$ ^# T! J! _$ J% b
int cbString, // number of characters in string # i: h: x4 f5 x, [2 H
LPSIZE lpSize // address of structure for string size
/ F& z. s" L1 r a; P& o& d9 c6 N);
* J+ a, [0 F, B4 R9 _; h+ }===============================================================================
. B$ o) B8 M$ d) S" u& uThe EnumFontFamilies function enumerates the fonts in a specified font family that are available on a specified device. This function supersedes the EnumFonts function.
2 \5 i6 w) S% T: [/ H- uint EnumFontFamilies(& M0 i+ m& H6 b4 l' [' \8 M
HDC hdc, // handle to device control
3 Y& v# W2 K- c# r: `LPCTSTR lpszFamily, // pointer to family-name string
6 i- y1 T; Z9 w5 a) YFONTENUMPROC lpEnumFontFamProc, // pointer to callback function
; e9 g* @7 |( {* ]0 D) t2 I' CLPARAM lParam // address of application-supplied data ' @9 x S4 |" u2 O9 x* n
);6 e" X; m1 V+ S+ x* o: k
# z, l- H( T/ u" I l
Parameters1 n! S8 I0 q7 N6 k: Y; F
hdc
/ k4 s" ]+ s; X( f3 ?/ EIdentifies the device context.
5 J7 d+ S$ D5 e( a' e3 UlpszFamily
- ?& f* h4 N+ [3 T2 p, X0 _) ~Points to a null-terminated string that specifies the family name of the desired fonts. If lpszFamily is NULL, EnumFontFamilies randomly selects and enumerates one font of each available type family. 2 |* q. {( b0 Z3 m3 L4 o
lpEnumFontFamProc
. F$ {5 I5 Q1 M% Q) C8 H5 N% dSpecifies the procedure-instance address of the application-defined callback function. For information about the callback function, see the EnumFontFamProc function.
8 w* H! ]% R. F) e0 z* |7 S, {lParam
4 B5 m$ x; r& `2 b2 UPoints to application-supplied data. The data is passed to the callback function along with the font information. ! I+ u! L1 P+ l0 q) J
/ v, C: y/ s( H0 X/ I2 T/ B
Return Values
$ W9 A J u+ s' ^3 H' xIf the function succeeds, the return value is the last value returned by the callback function. Its meaning is implementation specific.
1 V& s( x& y. r6 M7 r0 @. d& N$ x=============================================================================
9 w3 v9 ?6 i0 x5 @The EnumFontFamiliesEx function enumerates all fonts in the system that match the font characteristics specified by the 7 T: J) Z. t9 {6 |
LOGFONT structure. EnumFontFamiliesEx enumerates fonts based on typeface name, character set, or both. It is recommended that Win32-based applications use this function rather than EnumFontFamilies to enumerate fonts.; b2 V" T4 |& x. w% x5 g9 f
# G/ g1 D% ^& a2 R6 D
int EnumFontFamiliesEx(, m+ {8 T. M3 c- S( h8 P! n! k
HDC hdc, // handle to device context
+ x( T# K9 i. z9 ? ^# NLPLOGFONT lpLogfont, // pointer to logical font information. g4 i F- e8 J0 C7 o" T: N
FONTENUMPROC lpEnumFontFamExProc, // pointer to callback function
1 ^, ~4 Z% S; k7 z2 E. {LPARAM lParam, // application-supplied data ~9 t4 \% U( F: x1 p
DWORD dwFlags // reserved; must be zero2 ]/ @% g6 W( s- U: N* Q# @1 d7 t
); Q( A% X& c3 f9 D
=================================================================================
5 k7 E! }. y& [The EnumFonts function enumerates the fonts available on a specified device. For each font with the specified typeface name, the EnumFonts function retrieves information about that font and passes it to the application-defined callback function. This callback function can process the font information as desired. Enumeration continues until there are no more fonts or the callback function returns zero.
& J: ]. U, K4 z( _This function is provided for compatibility with earlier versions of Microsoft Windows. Win32-based applications should use the EnumFontFamilies function.
- y O0 u! a& L8 |+ U5 c C5 d2 R# P# i! Z5 W: d D! R7 ?
int EnumFonts( \- f n) T" r/ O+ Q
HDC hdc, // handle to device context
3 [! z; @7 g( |( Q! F: jLPCTSTR lpFaceName, // pointer to font typeface name string
4 l; s7 E$ I- b) s/ D$ V: G& w: AFONTENUMPROC lpFontFunc, // pointer to callback function
% @: k2 {* t; m" g8 hLPARAM lParam // address of application-supplied data
; G; N9 u% M0 d$ v);
# g! i1 U" b/ r ^( D' x, y3 V g) y
* i9 ]5 n8 `' y' D& f3 r$ [; MParameters
o0 r- I3 D! k B. khdc
) Z0 n% }! l$ \3 S' \Identifies the device context. 0 L2 |6 d* |2 a: b8 g! z1 X" C
lpFaceName
0 U j2 D7 |1 `Points to a null-terminated character string that specifies the typeface name of the desired fonts. If lpFaceName is NULL, EnumFonts randomly selects and enumerates one font of each available typeface. * a _* P' c0 c0 U- c/ M
lpFontFunc" B- ]8 {5 l% c$ n5 x3 X. f9 R
Points to the application-defined callback function. For more information about the callback function, see the EnumFontsProc function. , j. R3 B6 g0 a( \( _3 p; M6 N: {* W
lParam
( Z4 Z+ o: W# ^% D* y% e5 FPoints to any application-defined data. The data is passed to the callback function along with the font information.
- u$ \3 n) E) o* B* v2 c6 X
! p) f) w* D: K6 v& H7 b6 @( G$ L' |1 b3 l% ?+ Y
Return Values
- }* G$ V' q YIf the function succeeds, the return value is the last value returned by the callback function. Its meaning is defined by the application.
/ {6 R+ O/ L% ~ \======================================================================
4 a/ v; R# W" S% X2 o' i3 z: gThe GetSystemDefaultLangID function retrieves the system default language identifier.
( d+ e T5 X" D7 k9 i, |2 I, k) l7 D4 l4 Y' b, D, a
LANGID GetSystemDefaultLangID(VOID)
, F8 L4 E, F- a, }/ |' V+ g2 e
6 ?# t/ Q! v+ O$ N; rParameters8 R* h3 M2 u0 o* m0 @8 q8 j
This function has no parameters.
X4 C$ @ E$ R4 F% `! N" OReturn Values
+ ~1 C1 D! J4 D7 f* b1 JIf the function succeeds, the return value is the system default language identifier.
- j- m$ s% r+ s; b# @================================================================================
- d8 B2 b& S* b# I+ LThe GetUserDefaultLangID function retrieves the user default language identifier.
6 B, ]# ]; k+ w! M+ n- Y
7 f5 Y! S- Y$ `8 `' `# TLANGID GetUserDefaultLangID(VOID)! c1 }; @ G8 K9 W# u
9 t: |9 }# |3 s7 \( oParameters
' F% x! m* K, u9 c" J# n$ c4 CThis function has no parameters. / U @5 b4 A, ^8 T5 s; R% D8 z
Return Values
u* N( e8 {, q( t; m% OIf the function succeeds, the return value is the user default language identifier.
! _" w& l6 a# j# |. d================================================================================
4 ~0 u. K8 s& m$ ^
; p+ M4 C) z; i, wBOOL GetStringTypeA(
; N |+ Y$ C( k1 f# X7 \3 H6 \6 }, O8 b5 r; _2 F: f
LCID Locale, // locale identifer
9 V% n0 \1 y6 r! e& x1 v* r$ _DWORD dwInfoType, // information-type options
6 J7 u; X+ Q% g, Q% a( X5 JLPCSTR lpSrcStr, // pointer to the source string 6 \, k# q5 m0 L2 \* b+ |. X
int cchSrc, // size, in bytes, of the source string 1 j& b. E3 u' i8 [/ [5 R
LPWORD lpCharType // pointer to the buffer for output " L2 E" U; ~9 b
);
3 b2 n3 `. L0 c8 O; V. \. o/ `Parameters
+ O0 K9 K0 u! Q8 K |$ \% wLocale' R4 B4 U i4 B) x
LOCALE_SYSTEM_DEFAULT Default system locale
3 T2 G, H# {, `: z: ?$ S+ gLOCALE_USER_DEFAULT Default user locale
$ r+ Q3 [* [1 AdwInfoType
; @" g$ _; A* m* x& A5 DCT_CTYPE1 Retrieve character type information.
' s1 P7 A8 d; g, [CT_CTYPE2 Retrieve bidirectional layout information.
! A9 [! M; |, W% ACT_CTYPE3 Retrieve text processing information.
1 J7 \+ H+ [+ r8 N) DlpSrcStr
6 j( L5 M2 U0 K# O' Y/ f3 Y' wPoints to the string for which character types are requested. If cchSrc is -1, the string is assumed to be null terminated. This must be an ANSI string. Note that this can be a double-byte character set (DBCS) string if the locale is appropriate for DBCS.
5 z- q# M" l: d% @cchSrc
% v' y+ a" G7 r9 r: [Specifies the size, in bytes, of the string pointed to by the lpSrcStr parameter. If this count includes a null terminator, the function returns character type information for the null terminator. If this value is -1, the string is assumed to be null terminated and the length is calculated automatically.
9 k. [6 i6 J/ @7 ~% slpCharType' {6 B( `+ E! Q0 W& ^9 k. G- y- @2 W+ H
Points to an array of 16-bit values. The length of this array must be large enough to receive one 16-bit value for each character in the source string. When the function returns, this array contains one word corresponding to each character in the source string.
* Z5 L7 S1 W( A* w) }8 n4 l
- G2 D. ~- c6 s/ KReturn Values
' v: q- ~ ~( \ X! U; XIf the function succeeds, the return value is nonzero.
. Z+ d: t" K/ s8 m4 S- M=================================================================
0 u2 ]3 f# C; M, E9 W7 M$ jBOOL GetStringTypeW(
$ y6 i, z4 U: h1 A4 e1 L0 U& t5 a$ }6 {. X6 ^% U+ S( n- q
DWORD dwInfoType, // information-type options 1 N$ M" o5 O; M( [( D" h& r1 {
LPCWSTR lpSrcStr, // address of source string 5 w/ j' o9 \" W) i# q0 @6 _2 D
int cchSrc, // number of characters in string * T. V% Y$ G! H$ J8 x
LPWORD lpCharType // address of buffer for output
5 _) T1 X* c; i);
' h; m* A# v; X& W& X0 I& s9 y==========================================================================2 V8 g) F( J: C! {
The GetSystemDefaultLangID function retrieves the system default language identifier.
7 Y% ]! ?' E; V4 g* Y' bLANGID GetSystemDefaultLangID(VOID)
: D0 M" ^! X* f5 a- A
; L$ K0 a0 r+ W; A3 l
1 D; v2 ?; E- Z* |Parameters
) \* C, Q8 K( d. W% r1 d) X) BThis function has no parameters. & j% |& V5 v* n2 g6 r
+ ~: [- R, y% U, r4 a' O
Return Values
' T& t+ T3 M, k9 z4 vIf the function succeeds, the return value is the system default language identifier.
: S9 p9 F1 [$ ?2 Z9 g7 `" Q7 M" }9 ^+ G* h
Remarks) D5 y' |4 N1 R) [
For more information about language identifiers, see Language Identifiers and Locales.
- ~2 z. f8 F T2 o===============================================================================- S: ]. t7 x* n) _
int WideCharToMultiByte(
) u# g' P+ n6 \0 l& O) J i6 e# o/ z: I1 }$ \3 r2 o
UINT CodePage, // code page
& _) E3 M0 L$ T9 O. rDWORD dwFlags, // performance and mapping flags 1 z7 R& ^9 Z. l! _5 X. V1 V& H
LPCWSTR lpWideCharStr, // address of wide-character string 1 ~/ m8 x) \0 K2 o6 x& ]
int cchWideChar, // number of characters in string 6 `% z# ^; q$ p9 e; w
LPSTR lpMultiByteStr, // address of buffer for new string
, Q/ r7 s4 i1 V' Z* y. Y. `int cchMultiByte, // size of buffer ) o- L* y( Y& A( r R0 f% q; u: H4 ?
LPCSTR lpDefaultChar, // address of default for unmappable characters ) V/ p, ^0 L1 W; `
LPBOOL lpUsedDefaultChar // address of flag set when default char. used
# f8 z# [) V# x9 m); / q* n+ P3 }. y0 c }' G
* c9 `" n+ U) k' N \ m, M$ h$ ~$ M' f& A- s
Parameters- Z$ [7 c6 {) v; m! K) Z
+ C* B% k% ?- r7 H2 v0 zCodePage" g" R$ ^: i, w- o7 @7 ?1 u
Specifies the code page used to perform the conversion. This parameter can be given the value of any codepage that is installed or available in the system. The following values may be used to specify one of the system default code pages: ) }& q& S6 n+ I
. L) n1 r/ k. |7 i$ l5 k1 Y
Value Meaning' [1 V* r5 q4 ?: m: B3 [2 A
CP_ACP ANSI code page
' @/ h* i" H) X' B7 UCP_MACCP Macintosh code page$ p& y0 U1 L. _% x$ K! k9 Y1 @' _
CP_OEMCP OEM code page+ R/ J; I/ \. H! ^4 _" [# H
; X' b3 a0 |2 G8 O4 S" L: SdwFlags
! Z4 q8 N) _6 N: K6 x9 QA set of bit flags that specify the handling of unmapped characters. The function performs more quickly when none of these flags is set. The following flag constants are defined:3 a+ R9 G" X) A
! ?' x: q+ n. V3 ^; o% p* R
Value Meaning
/ h) L0 A6 F/ T" e; SWC_COMPOSITECHECK Convert composite characters to precomposed characters.) d2 t& x) c5 N4 R0 p* n" k: }4 p
WC_DISCARDNS Discard nonspacing characters during conversion.1 l$ s0 s! z1 ]6 G6 a
WC_SEPCHARS Generate separate characters during conversion. This is the default conversion behavior.. g1 C8 X) G2 r0 l
WC_DEFAULTCHAR Replace exceptions with the default character during conversion.
l+ o) o' {- A( H; L
: M9 k$ E* B' ], y% Q% f. WWhen WC_COMPOSITECHECK is specified, the function converts composite characters to precomposed characters. A composite character consists of a base character and a nonspacing character, each having different character values. A precomposed character has a single character value for a base/nonspacing character combination. In the character ? the
6 a: |4 i! n# q& t3 C6 ~% ]e is the base character, and the accent grave mark is the nonspacing character.
0 M; q6 l# B' d' G+ y
) S1 `: [2 D6 xWhen an application specifies WC_COMPOSITECHECK, it can use the last 3 flags in this list (WC_DISCARDNS, WC_SEPCHARS, and WC_DEFAULTCHAR) to customize the conversion to precomposed characters. These flags determine the functions behavior when there is no precomposed mapping for a base/nonspace character combination in a wide-character string. These last 3 flags can only be used if the WC_COMPOSITECHECK flag is set.
. W* V% @, r' n. C( nThe functions default behavior is to generate separate characters (WC_SEPCHARS) for unmapped composite characters.
* N- n2 q& _. o1 R0 i& |& N# L+ U2 G% P5 g& e, H
lpWideCharStr2 k2 P( }2 }5 P f
Points to the wide-character string to be converted.
4 |; {# x3 _/ x4 k# x5 x# Q/ l6 d6 K0 }5 r8 c: A; C
cchWideChar1 ?- ]. F3 b4 K) g4 b) t9 ^# D* L
Specifies the number of characters in the string pointed to by the lpWideCharStr parameter. If this value is -1, the string is assumed to be null-terminated and the length is calculated automatically. & X" P: U7 }: d- g
) \" X# z: ~) u+ plpMultiByteStr* [5 j) l2 K; X1 t
Points to the buffer to receive the translated string.
0 E& ~ k9 i& p& x4 h) U5 O6 @5 L) I3 @( R/ m
cchMultiByte! }' A7 F' {7 _
Specifies the size in characters of the buffer pointed to by the lpMultiByteStr parameter. If this value is zero, the function returns the number of bytes required for the buffer. (In this case, the lpMultiByteStr buffer is not used.)
* T* d. H- g# }! G: a! H Q" w6 Y. N z1 z, I% `
lpDefaultChar
7 |% J3 e: k# g5 \( }9 I; _Points to the character used if a wide character cannot be represented in the specified code page. If this parameter is NULL, a system default value is used. The function is faster when both lpDefaultChar and lpUsedDefaultChar are NULL. : ` i) ^9 q ~) ]& |9 s" H9 \) f# P
3 K( _, ]: V5 W3 MlpUsedDefaultChar
1 s8 b4 I8 k4 p: H* @; @" y1 lPoints to a flag that indicates whether a default character was used. The flag is set to TRUE if one or more wide characters in the source string cannot be represented in the specified code page. Otherwise, the flag is set to FALSE. This parameter may be NULL. The function is faster when both lpDefaultChar and lpUsedDefaultChar are NULL. ' a1 i6 u4 m) t! C6 H7 e" }
/ i2 u. D' y7 _3 t# l! x2 ]0 s$ A: ], R* G- T- D. s" |, j
3 T4 a R }+ cReturn Values
( O ^% N. V: D* Y$ X- [% _ W1 o2 |& |: F0 E/ u2 K
If the function succeeds, and cchMultiByte is nonzero, the return value is the number of bytes written to the buffer pointed to by lpMultiByteStr.
9 R5 N' O7 n# e& u' Q6 JIf the function succeeds, and cchMultiByte is zero, the return value is the required size, in bytes, for a buffer that can receive the translated string. 7 k7 a2 c! E0 s; \4 E" x
If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return one of the following error codes:; ]+ e6 q1 I& p1 x1 Z
( O" {1 N0 w5 i. o& B
ERROR_INSUFFICIENT_BUFFER
% n0 @# g/ V6 C; l$ PERROR_INVALID_FLAGS/ L* K4 u1 l: {4 K# I
ERROR_INVALID_PARAMETER |