@@ -17,8 +17,10 @@ import (
17
17
"unsafe"
18
18
)
19
19
20
- type Handle uintptr
21
- type HWND uintptr
20
+ type (
21
+ Handle uintptr
22
+ HWND uintptr
23
+ )
22
24
23
25
const (
24
26
InvalidHandle = ^ Handle (0 )
@@ -211,6 +213,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
211
213
//sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error)
212
214
//sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW
213
215
//sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId
216
+ //sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout
217
+ //sys toUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx
214
218
//sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow
215
219
//sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW
216
220
//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx
@@ -1357,9 +1361,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) {
1357
1361
func SetsockoptInet4Addr (fd Handle , level , opt int , value [4 ]byte ) (err error ) {
1358
1362
return Setsockopt (fd , int32 (level ), int32 (opt ), (* byte )(unsafe .Pointer (& value [0 ])), 4 )
1359
1363
}
1364
+
1360
1365
func SetsockoptIPMreq (fd Handle , level , opt int , mreq * IPMreq ) (err error ) {
1361
1366
return Setsockopt (fd , int32 (level ), int32 (opt ), (* byte )(unsafe .Pointer (mreq )), int32 (unsafe .Sizeof (* mreq )))
1362
1367
}
1368
+
1363
1369
func SetsockoptIPv6Mreq (fd Handle , level , opt int , mreq * IPv6Mreq ) (err error ) {
1364
1370
return syscall .EWINDOWS
1365
1371
}
@@ -1835,3 +1841,13 @@ func ResizePseudoConsole(pconsole Handle, size Coord) error {
1835
1841
// accept arguments that can be casted to uintptr, and Coord can't.
1836
1842
return resizePseudoConsole (pconsole , * ((* uint32 )(unsafe .Pointer (& size ))))
1837
1843
}
1844
+
1845
+ // ToUnicodeEx Translates the specified virtual-key code and keyboard state to
1846
+ // the corresponding Unicode character or characters.
1847
+ func ToUnicodeEx (virtualKey , scanCode uint32 , buf []uint16 , flags uint32 , layout Handle ) int32 {
1848
+ if len (buf ) == 0 {
1849
+ return 0
1850
+ }
1851
+ var keyState [256 ]byte
1852
+ return toUnicodeEx (virtualKey , scanCode , & keyState [0 ], & buf [0 ], int32 (len (buf )), flags , layout )
1853
+ }
0 commit comments