Skip to content

Commit 0b6690c

Browse files
committed
Add GetLocaleInfo
1 parent 308afe7 commit 0b6690c

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

kernel32.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ const (
3131

3232
// Predefined locale ids
3333
const (
34-
LOCALE_INVARIANT = 0x007f
35-
LOCALE_USER_DEFAULT = 0x0400
36-
LOCALE_SYSTEM_DEFAULT = 0x0800
34+
LOCALE_INVARIANT LCID = 0x007f
35+
LOCALE_USER_DEFAULT LCID = 0x0400
36+
LOCALE_SYSTEM_DEFAULT LCID = 0x0800
37+
)
38+
39+
// LCTYPE constants
40+
const (
41+
LOCALE_SDECIMAL LCTYPE = 14
42+
LOCALE_STHOUSAND LCTYPE = 15
3743
)
3844

3945
var (
@@ -44,6 +50,7 @@ var (
4450
closeHandle uintptr
4551
fileTimeToSystemTime uintptr
4652
getLastError uintptr
53+
getLocaleInfo uintptr
4754
getLogicalDriveStrings uintptr
4855
getModuleHandle uintptr
4956
getNumberFormat uintptr
@@ -66,6 +73,7 @@ type (
6673
HGLOBAL HANDLE
6774
HINSTANCE HANDLE
6875
LCID uint32
76+
LCTYPE uint32
6977
)
7078

7179
type FILETIME struct {
@@ -101,6 +109,7 @@ func init() {
101109
closeHandle = MustGetProcAddress(libkernel32, "CloseHandle")
102110
fileTimeToSystemTime = MustGetProcAddress(libkernel32, "FileTimeToSystemTime")
103111
getLastError = MustGetProcAddress(libkernel32, "GetLastError")
112+
getLocaleInfo = MustGetProcAddress(libkernel32, "GetLocaleInfoW")
104113
getLogicalDriveStrings = MustGetProcAddress(libkernel32, "GetLogicalDriveStringsW")
105114
getModuleHandle = MustGetProcAddress(libkernel32, "GetModuleHandleW")
106115
getNumberFormat = MustGetProcAddress(libkernel32, "GetNumberFormatW")
@@ -145,6 +154,18 @@ func GetLastError() uint32 {
145154
return uint32(ret)
146155
}
147156

157+
func GetLocaleInfo(Locale LCID, LCType LCTYPE, lpLCData *uint16, cchData int32) int32 {
158+
ret, _, _ := syscall.Syscall6(getLocaleInfo, 4,
159+
uintptr(Locale),
160+
uintptr(LCType),
161+
uintptr(unsafe.Pointer(lpLCData)),
162+
uintptr(cchData),
163+
0,
164+
0)
165+
166+
return int32(ret)
167+
}
168+
148169
func GetLogicalDriveStrings(nBufferLength uint32, lpBuffer *uint16) uint32 {
149170
ret, _, _ := syscall.Syscall(getLogicalDriveStrings, 2,
150171
uintptr(nBufferLength),

0 commit comments

Comments
 (0)