1: using System;
2: using System.Runtime.InteropServices;
3:
4: namespace TestingMentor.PInvoke
5: { 6: class NativeMethod
7: { 8: [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] 9: public static extern bool SetLocaleInfo(
10: uint locale,
11: uint localeType,
12: string localeData);
13:
14: [DllImport("kernel32.dll", SetLastError = true)] 15: public static extern bool SetLocaleInfo(
16: uint locale,
17: uint localeType,
18: int localeData);
19: }
20:
21: class NlsConstant
22: { 23: public enum Locale : uint
24: { 25: Invariant = 0x007F,
26: SystemDefault = 0x0800, // use system default for setlocaleinfo
27: UserDefault = 0x0400,
28: Neutral = 0x0000,
29: CustomDefault = 0X0C00, // Vista and later
30: CustomUiDefault = 0x1400, // Vista and later
31: CustomUnspecified = 0X1000 // Vista and later
32: };
33:
34: public enum LocaleType : uint
35: { 36: // VALUE LCDATA TYPES
37: CalendarType = 0x00001009, // type of calendar specifier
38: CurrencyDigits = 0x00000019, // local monetary fractional digits
39: CurrencySymbol = 0x0000001B, // position of positive currency symbol
40: FractionalDigits = 0x00000011, // number of fractional digits
41: NativeDigitSubstitution = 0x00001014, // native digit substitution
42: FirstDayOfWeek = 0x0000100C, // first day of week specifier
43: FirstWeekOfYear = 0x0000100D, // first week of year specifier
44: LeadingZeros = 0x00000012, // leading zeros for decimal
45: Measure = 0x0000000D, // 0 = metric, 1 = US
46: NegativeCurrency = 0x0000001C, // negative currency mode
47: NegativeNumber = 0x00001010, // negative number mode
48: PaperSize = 0x0000100A, // paper size
49: TimeFormat = 0x00000023, // time format specifier
50:
51: // STRING LCDATA TYPES
52: // Valid Unicode characters
53: AM = 0X00000028, // AM designator
54: PM = 0x00000029, // PM designator
55: CurrencySymbol = 0x00000014, // local monetary symbol
56: DecimalSeparator = 0x0000000E, // decimal separator
57: DigitGrouping = 0x00000010, // digit grouping
58: ListSeparator = 0x0000000C, // list item separator
59: LongDate = 0x00000020, // long date format string
60: MonetaryDecimalSeparator = 0x00000016, // monetary decimal separator
61: MonetaryGrouping = 0x00000018, // monetary grouping
62: MonetaryThousandSeparator = 0x00000017, // monetary thousand separator
63: NativeDigits = 0x00000013, // native ascii 0-9
64: NegativeSign = 0x00000051, // negative sign
65: PositiveSign = 0x00000050, // positive sign
66: ShortDate = 0x0000001D, // short date format string
67: ThousandSeparator = 0x0000000F, // thousand separator
68: TimeSeparator = 0x0000001E, // time separator
69: TimeFormat = 0x00001003, // time format string
70: YearMonthFormat = 0x00001006 // year month format string
71: };
72:
73:
74: public enum LocaleData : int
75: { 76: // LOCALE_ICALENDARTYPE VALUES
77: Gregorian = 1, // Gregorian (localized)
78: GregorianUS = 2, // Gregorian(Always English)
79: GregorianMEFrench = 9, // Middle East French
80: GregorianArabic = 10,
81: GregorianXlitEnglish = 11, // transliterated English
82: GregorianXlitFrench = 12, // transliterated French
83: Japan = 3,
84: Taiwan = 4,
85: Korea = 5,
86: Hijri = 6,
87: Thai = 7,
88: Hebrew = 8,
89: Umalqura = 23, // Um Al Qura (Arabic lunar) Vista or later
90:
91: // LOCALE_ICURRENCY
92: PositiveCurrencyPrefixNoSeparation = 0,
93: PositiveCurrencySuffixNoSeparation = 1,
94: PositiveCurrencyPrefixSeparation = 2, // one character separation
95: PositiveCurrencySuffixSeparation = 3, // one character separation
96:
97: // LOCALE_IDIGITSUBSTITUTION
98: DigitSubstitutionContextBased = 0,
99: DigitSubstitutionNone = 1, // use this setting for full unicode support
100: DigitSubstitutionNative = 2, // uses digits based on national conventions
101: // according to LOCALE_SNATIVEDIGITS
102:
103: //LOCALE_IFIRSTDAYOFWEEK
104: Monday = 0, // LOCALE_SDAYNAME1
105: Tuesday = 1, // LOCALE_SDAYNAME2
106: Wednesday = 2, // LOCALE_SDAYNAME3
107: Thursday = 3, // LOCALE_SDAYNAME4
108: Friday = 4, // LOCALE_SDAYNAME5
109: Saturday = 5, // LOCALE_SDAYNAME6
110: Sunday = 6, // LOCALE_SDAYNAME7
111:
112: // LOCALE_IFRISTWEEKOFYEAR
113: FirstDay = 0, // Week containing 1/1 even if single day
114: FirstFullWeek = 1, // first full week following 1/1
115: FirstWeek = 2, // first week with at least 4 days after 1/1
116:
117: // LOCALE_ILZERO
118: NoLeadingZero = 0, // .975
119: LeadingZero = 1, // 0.975
120:
121: // LOCALE_IMEASURE
122: Metric = 0,
123: US = 1,
124:
125: // LOCALE_INEGCURR
126: ParenthesisSymbolNumber = 0, // ($1.1)
127: NegativeSignSymbolNumber = 1, // -$1.1
128: SymbolNegativeSignNumber = 2, // $-1.1
129: SymbolNumberNegativeSign = 3, // $1.1-
130: ParenthesisNumberSymbol = 4, // (1.1$)
131: NegativeSignNumberSymbol = 5, // -1.1$
132: NumberNegativeSignSymbol = 6, // 1.1-$
133: NumberSymbolNegativeSign = 7, // 1.1$-
134: NegativeSignNumberSpaceSymbol = 8, // -1.1 $
135: NegativeSignSymbolSpaceNumber = 9, // -$ 1.1
136: NumberSpaceSymbolNegativeSign = 10, // 1.1 $-
137: SymbolSpaceNumberNegativeSign = 11, // $ 1.1-
138: SymbolSpaceNegativeSignNumber = 12, // $ -1.1
139: NumberNegativeSignSpaceSymbol = 13, // 1.1- $
140: ParenthesisSymbolSpaceNumber = 14, // ($ 1.1)
141: ParenthesisNumberSpaceSymbol = 15, // (1.1 $)
142:
143: // LOCALE_INEGNUMBER
144: Parenthesis = 0, // (1)
145: NegativeSignNumber = 1, // -1
146: NegativeSignSpaceNumber = 2, // - 1
147: NumberNegativeSign = 3, // 1-
148: NumberSpaceNegativeSign = 4, // 1 -
149:
150: // LOCALE_PAPERSIZE
151: USLetter = 1,
152: USLegal = 5,
153: A3 = 8,
154: A4 = 9,
155:
156: // LOCALE_ITIME
157: FormatAM_PM = 0,
158: Format24Hour = 1
160: };
161: }
162: }