diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-03 02:06:11 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-03 02:06:11 -0400 |
| commit | d8ee23ff740d80ad365bc6eb4b32ce3100198e8f (patch) | |
| tree | 01f2f348f8ff467dd910353d86ae188fbdaed831 | |
| parent | fb8e64cb5a1cec37f3c6293e41ea1fe87ff0107d (diff) | |
Added convenience functions to the Windows backend for UTF-16 string handling. I'll convert the existing code to use it shortly.
| -rw-r--r-- | common_windows.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common_windows.go b/common_windows.go index 2a403c7..2c1c3fd 100644 --- a/common_windows.go +++ b/common_windows.go @@ -71,6 +71,18 @@ func negConst(c int) uintptr { return uintptr(c) } +// the next two are convenience wrappers +// the intention is not to say utf16ToArg(toUTF16(s)) - even though it appears to work fine, that's just because the garbage collector is slow; if we store this globally then things will break +// instead, call them separately - s := toUTF16(str); winapifunc.Call(utf16ToArg(s)) + +func toUTF16(s string) *uint16 { + return syscall.StringToUTF16Ptr(s) +} + +func utf16ToArg(s *uint16) uintptr { + return uintptr(unsafe.Pointer(s)) +} + var ( _adjustWindowRectEx = user32.NewProc("AdjustWindowRectEx") _createWindowEx = user32.NewProc("CreateWindowExW") |
