summaryrefslogtreecommitdiff
path: root/common_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-03 02:06:11 -0400
committerPietro Gagliardi <[email protected]>2014-06-03 02:06:11 -0400
commitd8ee23ff740d80ad365bc6eb4b32ce3100198e8f (patch)
tree01f2f348f8ff467dd910353d86ae188fbdaed831 /common_windows.go
parentfb8e64cb5a1cec37f3c6293e41ea1fe87ff0107d (diff)
Added convenience functions to the Windows backend for UTF-16 string handling. I'll convert the existing code to use it shortly.
Diffstat (limited to 'common_windows.go')
-rw-r--r--common_windows.go12
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")