字体、语言相关的API函数原型:: U% Q" G- `& r
# z" G5 L& G& h5 O6 T, O: K+ q }createFont 用指定的属性创建一种逻辑字体 + n( R+ A+ w; ? P$ d) Z
createFontIndirect 用指定的属性创建一种逻辑字体 9 g/ {; [& C+ W/ ~
GetStockObject 取得一个固有对象(笔、刷子、字体等): L8 n4 H; F1 o5 N( ?+ z
) [7 {/ U# f4 D5 n4 c6 x3 pGetACP 检取ANSI系统代码页的标识符9 g' B/ }& V. e" X" W
GetOEMCP 检取系统的OEM代码页标识符
! A$ I6 w7 `7 @! O- nGetTextExtentPoint 判断一个字串的大小(范围)(用于限制输入)- d3 F$ y4 n: Y! Q% K' C
EnumFontFamilies 列举指定设备可用的字体2 D% c6 F p, V9 T$ m
EnumFontFamiliesEx 列举指定设备可用的字体
+ A E! S; s0 k' x8 n; EEnumFonts 列举指定设备可用的字体
( n% y+ f8 F3 i: uGetSystemDefaultLangID 取得系统的默认语言ID
) n* X) _* K4 I9 p( e5 e6 cGetUserDefaultLangID 为当前用户取得默认语言ID3 `' g7 T( e- W9 ~. l
GetStringTypeA 获取ANSI字符串类型 ,返回指定字符串的字符类型信息
+ A! O5 I- k: x7 S& p* Z: QGetStringTypeW 返回一个Unicode串的字符类型信息
# q* @. b; V! lGetSystemDefaultLangID 检取系统缺省语言标识符
: f& W: d- q4 jWideCharToMultiByte 把一个宽字符串映射为一个新字符串
0 z8 V1 Z9 G# H4 p" P) T5 }# ~/ H/ ~
=====================================================================. c7 f8 @! X: x4 k" R2 ?% a. V. u
/ R% L0 o: ~/ m1 @- ]0 pHFONT CreateFont(
; v* C) e3 |" L1 b; _) A. H. T% V: Z. U. i5 ^
int nHeight, // logical height of font ; c: z) V6 M8 g' v
int nWidth, // logical average character width
- C1 v7 M3 V$ Qint nEscapement, // angle of escapement 0 t* p8 @1 N& _9 }" U5 M4 _
int nOrientation, // base-line orientation angle
3 z H, k; u' y! L! Qint fnWeight, // font weight 6 ~, J, D/ e( M* q1 C
DWORD fdwItalic, // italic attribute flag
" [' H8 X" D6 n3 a+ h( L5 wDWORD fdwUnderline, // underline attribute flag
4 z2 h; T8 G1 j( }$ h; {) U6 RDWORD fdwStrikeOut, // strikeout attribute flag : H% z- h7 d7 U; n1 F+ G& _% U
DWORD fdwCharSet, // character set identifier
/ c9 I8 z9 u& q. y5 fDWORD fdwOutputPrecision, // output precision 3 Y; d" l9 }% C) }: V! E+ M
DWORD fdwClipPrecision, // clipping precision
' {& T! R$ C- j3 f! Q+ ]DWORD fdwQuality, // output quality ) C" H4 V" B9 R5 U2 n" N9 A: m
DWORD fdwPitchAndFamily, // pitch and family
8 R, |. I0 @: }* [* |4 s; \LPCTSTR lpszFace // pointer to typeface name string
# i$ l5 k' a$ U3 U/ d; N; c);$ l* R9 _! C. m( Q7 p
! |. C$ u0 R- k2 r
==========================================================================
" A E% p4 \ Y8 o# ]HFONT CreateFontIndirect($ ?# | N i! u$ N a
" [! `; P" y, j1 w; d1 y5 J
CONST LOGFONT *lplf // pointer to logical font structure
& |9 C# t+ E: O, L);' \( b# ~# J5 l6 V* `# M$ n' T
$ C' R! B+ Y: M( [
==========================================================================
3 W: {5 T8 K' _! `: B- pHGDIOBJ GetStockObject(
+ J$ [# ]5 Y4 Q$ G7 z1 e9 A" ?9 T! K& D `/ a
int fnObject // type of stock object
& U# I4 _5 `: \4 x6 w4 I2 |3 s! x);9 N& z* c( M8 z1 I7 s* M
6 X9 m8 a; G# p: J. w' j" b! j2 [' A' p% D5 L, B" T
fnObject" l. i7 U6 |8 N& j0 e. I
Specifies the type of stock object. This parameter can be any one of the following values: 8 u" A9 r2 ~: T- z5 b* j7 q6 R
Value
7 B0 n1 _: {( U& ~4.BLACK_BRUSH Black brush.
2 k8 u5 a* R( u! ~$ G1 j! l8 n3.DKGRAY_BRUSH Dark gray brush. h- s$ Z2 I3 G$ K x7 j5 s- ]) u3 O
2.GRAY_BRUSH Gray brush.0 k7 O4 w$ q3 v0 K3 k9 p- }) c
5.HOLLOW_BRUSH Hollow brush (equivalent to NULL_BRUSH).; G# ~. Q' z- F, ]0 P
1.LTGRAY_BRUSH Light gray brush.! K& R9 D) e# }( C, S
5.NULL_BRUSH Null brush (equivalent to HOLLOW_BRUSH).
. k6 x) O' P! v" P" E7 |2 c0.WHITE_BRUSH White brush.
: U/ x: a: ?- F) F0 R" f; c7.BLACK_PEN Black pen.3 e+ g/ i6 m- x3 D3 o
8.NULL_PEN Null pen.
* {% L. R8 c% }& B' j+ x. E' c6.WHITE_PEN White pen." g5 D. Q6 g8 K5 }5 @
11.(0B)ANSI_FIXED_FONT Windows fixed-pitch (monospace) system font./ d" S& Q' m9 x
12.(0C)ANSI_VAR_FONT Windows variable-pitch (proportional space) system font.7 \1 k! R7 k: x
14.(0E)DEVICE_DEFAULT_FONT Windows NT only: Device-dependent font.( a( v, _3 c: x
17.(11)DEFAULT_GUI_FONT Windows 95 only: Default font for user interface objects such as menus and dialog boxes.(一般选这种)
4 d6 ^9 S! K: w; v" T% v1 \! D10.(0A)OEM_FIXED_FONT Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font.
1 P' S9 R& d8 b/ l6 d$ g }3 Q13.(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.
5 w7 Z* \, J3 O& v4 m, n16.(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.% K5 q5 F: A3 s4 g. b: {% V
15.DEFAULT_PALETTE Default palette. This palette consists of the static colors in the system palette.
5 `; k3 \/ }8 X/ OIf the function succeeds, the return value identifies the logical object requested.6 }" ?' p$ G( C0 s9 w( }! l+ G2 r
If the function fails, the return value is NULL. + p5 Q# x8 u( r& q- M# I! ^ E+ d. F
=================================================================================$ Y& F. Q. W! ?/ y2 H
The GetACP function retrieves the current ANSI code-page identifier for the system.! k6 t |- v9 Z* J
UINT GetACP(VOID)) ~# I5 e, B" @7 r# p
0 H: c' p; ~" {) _7 G( s0 ?9 A* HParameters" ~' k! r, x7 r9 S1 e
This function has no parameters.
' G# B* D" K5 J. i0 d, eReturn Values
# Y6 Y$ e/ L, T% G nIf 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.
: O* I+ p8 U2 ORemarks
2 Z- ]1 l+ t A( z) A5 D3 R. FFollowing are the ANSI code-page identifiers:
2 ]0 O+ G2 Y) K7 g+ hIdentifier Meaning( ^+ L4 p- O$ N
874 Thai
B9 i: C" G: j/ x* X8 Y( r932 Japan
6 n5 |3 t) b- |; U936 Chinese (PRC, Singapore)
' y0 V8 C; F+ G) y2 h8 F) \- b949 Korean
: W( T1 E0 j. k3 w6 S2 E950 Chinese (Taiwan, Hong Kong)
0 `$ E3 N; S. E9 Y1200 Unicode (BMP of ISO 10646)2 s# _, i# g. Z
1250 Windows 3.1 Eastern European
& k2 D0 ^' `6 e5 K1251 Windows 3.1 Cyrillic
2 C$ m. s+ X/ G* }1252 Windows 3.1 Latin 1 (US, Western Europe)
. }6 G; k r; f h' C3 a( T- l1253 Windows 3.1 Greek: Q; ?5 P8 B8 y4 t1 } `6 U; ~
1254 Windows 3.1 Turkish: ?, d) w5 ?: _4 N# B3 W, G Q
1255 Hebrew
/ D5 B/ D1 ^$ ~, X$ _9 K+ ]/ A1256 Arabic; A8 N+ B* f0 X* n3 }* i
1257 Baltic1 C/ k2 q0 j9 H1 `0 w: i
=============================================================================
8 Y4 w* T3 Q, `: q4 R; R& vThe GetOEMCP function retrieves the current OEM code-page identifier for the system. (OEM stands for original equipment manufacturer.)
( g5 R/ K/ ^+ R% \0 P/ R+ v* e( J
C' d& ~ o/ sUINT GetOEMCP(VOID)) q4 O5 ^ _+ b9 E% d$ J
; i$ r$ M1 m0 z1 }
; e' h! M3 @; w' I
Parameters
* r, u( }' G6 Y* w: u
) V9 @' a5 P( A& z- m8 LThis function has no parameters.
9 G' L, {% J+ u3 h# c# r* f" T) H! j. w
Return Values4 w4 x# T0 E# f3 [
' b7 g0 p1 n+ a5 z' l8 E: [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.: E7 O6 H& f9 l$ b# N. H% G6 @
' ~6 A7 A0 L8 i9 c0 Y0 W
Remarks
, m/ g/ s: h% f3 I+ a% B3 C, j1 }) S$ i0 c; B, l( v! i# u+ P2 D
Following are the OEM code-page identifiers: $ o$ I6 P. H$ Q" {" ]8 S3 r
! V6 W$ B. w8 F: ^% f7 JIdentifier Meaning3 C* _- P$ u4 ^6 L: e
437 MS-DOS United States* K$ e5 c1 A7 t
708 Arabic (ASMO 708)5 P0 a/ {" E% O' z# w, J
709 Arabic (ASMO 449+, BCON V4)
: j) `& w6 u1 |& V710 Arabic (Transparent Arabic)/ I' T' [) P) j* c+ c Q# T9 v
720 Arabic (Transparent ASMO)
3 Z+ V) Q6 m# X737 Greek (formerly 437G)
- _1 w# D8 G( k$ ]775 Baltic! M L# u6 t& f- f# D% J
850 MS-DOS Multilingual (Latin I)8 v" c/ {1 G- P/ v& N9 U$ P! E6 e
852 MS-DOS Slavic (Latin II)
. w' P5 y k1 h, X8 q* M855 IBM Cyrillic (primarily Russian). j" R) J) @8 W! x- F+ j1 G
857 IBM Turkish0 {. h/ I5 ?9 ]9 r( f
860 MS-DOS Portuguese' w$ f) m2 _: K! f
861 MS-DOS Icelandic. K Q, P; B( b- b2 j7 u+ j
862 Hebrew
1 h* P- z: u9 P$ }! K8 \863 MS-DOS Canadian-French
% m8 Y5 o0 L1 Q) k5 }2 G864 Arabic
& `; B. m) ]* O4 o865 MS-DOS Nordic
+ Y% r0 y; n, N) O4 T866 MS-DOS Russian (former USSR)
* D$ o) Y. [0 c9 x& Q869 IBM Modern Greek& B4 ^/ j) y2 N% ` P2 u1 E* r: `
874 Thai7 ~9 x8 _* f1 X d* l
932 Japan
* j( Y/ F* e1 n' x( ^+ c936 Chinese (PRC, Singapore)
3 f8 @8 t0 K# X. j& h0 ?3 Q2 S- F949 Korean8 r' N( G* O# C
950 Chinese (Taiwan, Hong Kong)
f8 F0 N; k# [: A# M1361 Korean (Johab)! ^7 s8 h9 @' e7 T3 P
===============================================================================9 J7 b3 S% Z# S$ T
BOOL GetTextExtentPoint(
: }& o8 @8 l) U. ]. z# b& R5 x4 N: P! D' y- q; [
HDC hdc, // handle of device context
0 O8 T$ Y2 j3 MLPCTSTR lpString, // address of text string
$ i9 l% ]# W2 S, Fint cbString, // number of characters in string 7 w0 L4 F) e7 H
LPSIZE lpSize // address of structure for string size
( e8 R3 N: z* D/ M- v);2 q. v& T: L Q) n. T3 ]
===============================================================================
' Y8 \: U4 k/ P OThe EnumFontFamilies function enumerates the fonts in a specified font family that are available on a specified device. This function supersedes the EnumFonts function. ! m& V& k, ~( w" \6 y( s+ M! X! K. u7 ~
int EnumFontFamilies(* A0 w p# E5 n
HDC hdc, // handle to device control . [, W: K+ }: I# _4 o9 S) ?/ p. f
LPCTSTR lpszFamily, // pointer to family-name string
0 g/ s: C I- L/ S$ T! oFONTENUMPROC lpEnumFontFamProc, // pointer to callback function 1 O& J9 j, k% E' t* P
LPARAM lParam // address of application-supplied data # T2 E# q7 `$ Y1 v: t. I$ Z
);9 r* e+ s7 }; j. s! k- z
' {' a& o; a1 U6 ?: E1 H7 C6 }
Parameters7 ~8 k( _1 E9 |" [5 [
hdc
- i/ e# o# i6 `" o/ D# D; ]' v1 CIdentifies the device context. , D& x# g: T/ T3 p$ m
lpszFamily
# w' q! _0 m! ePoints 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. 3 w$ H' P2 G B3 t, K( k8 F! r
lpEnumFontFamProc0 Z7 ~3 B, Y s- u) M0 G
Specifies the procedure-instance address of the application-defined callback function. For information about the callback function, see the EnumFontFamProc function.
; E0 A% Z9 s& P: ^0 G5 ?' |. HlParam
0 V6 E- w L: f v( w8 H% B3 i* ?Points to application-supplied data. The data is passed to the callback function along with the font information. ' @6 B* A3 M* V9 T$ M5 e
. t& D# u* E% F* ]- X) v+ x
Return Values/ x3 N1 [0 W1 J7 Y9 c7 z
If the function succeeds, the return value is the last value returned by the callback function. Its meaning is implementation specific.
: o& S1 x" e1 y1 S3 s=============================================================================- M% d+ O& W# k% R. w
The EnumFontFamiliesEx function enumerates all fonts in the system that match the font characteristics specified by the
& M+ ?$ t, @" h3 m" G1 nLOGFONT 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.
/ k9 `0 S+ }& a$ Q' }* E7 C7 N0 K, {9 _- l
int EnumFontFamiliesEx(
- W6 p$ o& u1 X! PHDC hdc, // handle to device context6 Q6 x1 h4 ^# Z7 N& N) c& |5 k0 g
LPLOGFONT lpLogfont, // pointer to logical font information9 a5 o3 w8 r6 s2 K2 i* S
FONTENUMPROC lpEnumFontFamExProc, // pointer to callback function
5 E+ b: ~2 W- U$ U7 |LPARAM lParam, // application-supplied data0 G9 k7 z/ _/ ^
DWORD dwFlags // reserved; must be zero
. I& r; ~/ S6 Z8 o* y);
' R4 y5 \ w) v* P7 f=================================================================================
3 h2 o- u; C' W/ bThe 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. 6 s) F4 f! I! ^7 _% R$ c
This function is provided for compatibility with earlier versions of Microsoft Windows. Win32-based applications should use the EnumFontFamilies function.
& R: D. N* @& q' d+ j
5 e+ ?7 G d Qint EnumFonts(
! O; i4 [- i6 @' k: g3 X/ [* D$ `HDC hdc, // handle to device context
& ]& _, k- o6 x# T. Q; j/ ]& mLPCTSTR lpFaceName, // pointer to font typeface name string
; o9 w% Q7 U* d* `! kFONTENUMPROC lpFontFunc, // pointer to callback function 1 a" y8 ~% P1 V1 R! l: z+ l; R& q
LPARAM lParam // address of application-supplied data 2 h3 J+ s k5 [1 l
); 8 J- U# T$ d# k, u9 U3 a
& y. k3 r" J! Y+ Z s XParameters- x- R8 f8 h7 w- m% e" y: v2 I
hdc) k) k) A9 y6 U7 M& m a
Identifies the device context.
5 i- l7 Q' I2 ~( xlpFaceName
- M9 u* k/ ~/ B5 ]; RPoints 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. 4 h5 N& h, N7 y& F% O
lpFontFunc
4 D# p$ t9 F* J, H/ v+ a/ }) DPoints to the application-defined callback function. For more information about the callback function, see the EnumFontsProc function.
- ~0 h. Q" g9 ~) V% ClParam( h- S6 N3 f+ h( J3 x$ j6 {
Points to any application-defined data. The data is passed to the callback function along with the font information. 6 f5 r/ N, n) T! _; I
% x$ l/ r5 A9 ?& U9 l8 O" m2 y0 t$ C
Return Values/ L. q: O) `6 _/ m Q1 k
If the function succeeds, the return value is the last value returned by the callback function. Its meaning is defined by the application.
! @" m9 U4 _) h& w+ |/ @======================================================================
& r' N, q( V3 }+ `. I# iThe GetSystemDefaultLangID function retrieves the system default language identifier.
) I6 o: I, D5 K6 C x4 G8 ~1 @) g8 [ o) n6 L) S" p; k, @
LANGID GetSystemDefaultLangID(VOID)
4 ? M( r6 \% A6 F
0 `$ Z% B- N* R+ B% A' b9 J! YParameters% J. Y% |, ~, g' l: | g# T
This function has no parameters. * G# v; f' a" Q- t1 j$ s7 J
Return Values
1 D3 ?. A. d* d2 jIf the function succeeds, the return value is the system default language identifier.. l6 ?8 F2 ` v$ f3 \* j9 m7 Y7 D7 Z: Z
================================================================================- ~( H u% N$ e: r5 k- M6 _1 Y
The GetUserDefaultLangID function retrieves the user default language identifier.
& h6 j1 G# r) l# M* A7 G5 [" _. E4 S
LANGID GetUserDefaultLangID(VOID)) \ Q# q- Q$ y) c) V
8 L& j2 {; c( {9 a7 ]/ gParameters$ t& w5 _3 R% |, |+ ~7 C4 A
This function has no parameters. 3 v* Z" R+ R4 z) R3 m
Return Values
. {* p8 ]4 I) I9 J) v# P# pIf the function succeeds, the return value is the user default language identifier.
0 i4 x2 Q5 G7 M$ Q( z: u/ l================================================================================
% P% l$ J; Q: G, X* s
; k0 k& D; k8 y* MBOOL GetStringTypeA( ] q5 d8 k5 O: ?! O9 \, j
7 h8 p+ \; e1 {: x. Z
LCID Locale, // locale identifer7 A! e' x5 {. L" o. [
DWORD dwInfoType, // information-type options 7 A" d. g( u, r0 F+ \1 g7 v
LPCSTR lpSrcStr, // pointer to the source string ' s2 W ?( P. b" ?4 h; K
int cchSrc, // size, in bytes, of the source string + _4 I; Z2 ^% B+ w5 N! A- ]( g/ `7 X: h
LPWORD lpCharType // pointer to the buffer for output
- a9 c' b0 R! B: ?# {4 p2 t( N);
m* Q L; b K& [; ^* M: b3 HParameters+ H3 {2 y4 J# j+ F* I
Locale! H4 o5 h' C' e( Q) V* C! @
LOCALE_SYSTEM_DEFAULT Default system locale
' e3 L! l$ G: kLOCALE_USER_DEFAULT Default user locale
$ M0 h4 l7 J, @9 e7 b) pdwInfoType
+ }4 m, g+ i/ t- Y8 o( \! d/ L+ nCT_CTYPE1 Retrieve character type information.
- {- S% w9 x. u+ \+ kCT_CTYPE2 Retrieve bidirectional layout information.
. W) ~' u' z8 M( ZCT_CTYPE3 Retrieve text processing information.
0 t1 Q4 k2 B7 @+ ?& g. }/ s% j; |& mlpSrcStr
/ {7 O- w. \3 J# D) pPoints 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.
- y) `5 m. U% N( PcchSrc
" }" g5 X7 k5 B1 R" v3 K, B' O9 OSpecifies 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. # L; S! I8 U% b9 [5 X
lpCharType
$ a$ I3 W6 f1 s( ~, t) g! VPoints 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. 4 n, ]5 `- j- ]
* v- u9 i; {. |7 _/ h
Return Values
% Q6 T* g. ]& H# G* {1 M/ sIf the function succeeds, the return value is nonzero.
& O5 ~& @" O& K- D) Q8 Y7 M9 [! i=================================================================4 @! _( F! \8 S1 W9 ^
BOOL GetStringTypeW(
! Z/ J5 J7 u) K
+ u! `2 c% n- g1 `2 F- RDWORD dwInfoType, // information-type options $ J* Z; T. f6 h" x6 B2 `
LPCWSTR lpSrcStr, // address of source string
. e. z1 a& m0 Tint cchSrc, // number of characters in string . N2 z3 x1 V: y! b' I X5 S0 x/ B
LPWORD lpCharType // address of buffer for output
: S8 W8 Z" @% e- U2 G);$ n. l0 G5 C; |, m. M
==========================================================================3 c4 L7 }2 V$ C( o! N; Z; u$ q
The GetSystemDefaultLangID function retrieves the system default language identifier.
7 ^) T7 s/ [) K' T! iLANGID GetSystemDefaultLangID(VOID), h1 Q, a9 f" |
6 |2 N4 k0 G8 N$ e- }: m% X8 q) | \* r. M
Parameters
1 s' r" m% F) e( C$ FThis function has no parameters. ?/ N/ V5 e: A* D Y- l6 }2 P
2 R) O# i8 L ]' a' u& G8 a% w
Return Values
! W! r6 ~- ^0 s# x% V; VIf the function succeeds, the return value is the system default language identifier.
+ ~ x2 @9 y4 X) ^7 m* N- N2 [; J7 g9 L1 u T
Remarks2 `# t" z. |+ ?* \
For more information about language identifiers, see Language Identifiers and Locales.8 C1 P6 Z3 g$ @2 _
===============================================================================* b0 _& p7 P% h# [ H+ u3 x
int WideCharToMultiByte(
: Z: U1 D" ?# M; T
; B. w- @1 K7 |& YUINT CodePage, // code page
% i# {3 S% U1 _ i6 q2 Q3 DDWORD dwFlags, // performance and mapping flags
$ H4 r* m9 e/ ]$ Q& }/ cLPCWSTR lpWideCharStr, // address of wide-character string 6 o$ F h$ p- N+ P" D, x) O# O
int cchWideChar, // number of characters in string
- r$ _& c y' f" Y( e; k+ vLPSTR lpMultiByteStr, // address of buffer for new string ' V+ m9 K% R6 v2 o* E' B. d( `
int cchMultiByte, // size of buffer & G6 M9 [) k! P! S# d% H
LPCSTR lpDefaultChar, // address of default for unmappable characters ' y$ ]/ s( k& A9 _- [
LPBOOL lpUsedDefaultChar // address of flag set when default char. used
; V# {6 Y: d/ o/ {- P% l. j( @);
& Q, W7 P! v9 ?$ t
' X0 U2 P _& `' B* g. k$ y+ ?: I: j$ n) M
Parameters; ?3 s" J2 y1 W
( ^ _& ~# h* g5 z! QCodePage
" `4 K6 |/ q' j3 a; t0 O" eSpecifies 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:
/ A0 |- P/ Q! k
3 S* L- @( ^8 V; sValue Meaning
9 j* W u' Y- Z& dCP_ACP ANSI code page8 \; F2 I* T# B6 j. K
CP_MACCP Macintosh code page1 }5 x4 t6 e: \1 z; X: r, {& q
CP_OEMCP OEM code page
& Z" m6 Z0 w, z9 {0 |0 f9 ?6 i: g, @( q, X( E# u: _- e
dwFlags
- b# r" l6 c* s* p5 EA 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:
2 @! G0 i G0 J0 C: Z4 t! c. [5 C" m0 \2 D: B$ B" C
Value Meaning" ^8 m- q r: l2 c* I
WC_COMPOSITECHECK Convert composite characters to precomposed characters.& k- c( C" ]2 P: W5 }0 n
WC_DISCARDNS Discard nonspacing characters during conversion.
3 V6 F& T$ J# E/ Y; ?4 `( AWC_SEPCHARS Generate separate characters during conversion. This is the default conversion behavior.! I- i$ m" W" x0 b9 x
WC_DEFAULTCHAR Replace exceptions with the default character during conversion.
0 `8 N; [+ z# E$ p8 L$ w( }8 J4 I
7 h3 S" M) c/ U; U7 @When 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
, ?+ S1 ^# U/ r/ T2 A! ]e is the base character, and the accent grave mark is the nonspacing character.0 j6 F- N$ `/ \
: ^6 H3 T. n% ?When 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.
5 L8 r- O$ U8 H3 ~( FThe functions default behavior is to generate separate characters (WC_SEPCHARS) for unmapped composite characters.+ k. [5 D, \/ h4 a! A9 {7 k/ f6 ]
0 }( P6 q& @ Y8 n" @
lpWideCharStr
$ w4 h) n, N5 VPoints to the wide-character string to be converted. 8 e& k( o2 q' \
3 M6 b& b0 @/ V2 x1 V+ J
cchWideChar2 W6 J& G: K( q2 I, K6 c+ d
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. ( E& S5 X) J. M$ Y4 ]' N
0 P0 L! u1 X- PlpMultiByteStr6 R" r h6 b' D6 P; V
Points to the buffer to receive the translated string. : z, h: U2 X+ T* u' V: L
6 c6 {! v( @, h' e% K( @# u
cchMultiByte
4 b: T7 U. ?' L5 qSpecifies 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.)
% _% k+ u1 I4 S$ J7 ~. a9 Z# w8 _5 v, J0 M& P+ ]3 ?8 S6 U. `7 R+ b
lpDefaultChar
8 X/ n8 m [0 ?% x8 H( nPoints 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.
! S8 R5 O, p& D
9 S# p, p" U( x4 L& i9 C8 U5 olpUsedDefaultChar
6 G0 ^/ u: [% ~/ j7 xPoints 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.
& A, R$ X& N- y, H3 [) u/ L; [5 ]: m
: W' w/ M9 E! C3 ]
: P: R# p. t( l
Return Values
& `( d$ s$ g4 {! j1 a6 w. h5 U" f
# S" w. u) E6 V. Z2 n. L IIf the function succeeds, and cchMultiByte is nonzero, the return value is the number of bytes written to the buffer pointed to by lpMultiByteStr.
# h5 C6 T9 R0 l5 k4 Z7 _If 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.
" s5 @, E U! n) G$ I! AIf the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return one of the following error codes:
7 a& [# A; `5 x
7 o3 J& V) \, {; dERROR_INSUFFICIENT_BUFFER
: _+ m! f- Z6 w; I" kERROR_INVALID_FLAGS- n0 I ^1 ?, g7 U6 A
ERROR_INVALID_PARAMETER |