#Windows API

14 messages · Page 1 of 1 (latest)

keen zinc
#

lock it with GlobalLock, then cast the result to the data type you specified in the call

#

(in general, a handle is just a piece of opaque data that you need to pass to another function to make any use of. sometimes they happen to be a pointer that you can cast directly, but that’s not guaranteed if it works, and could change in the future. sometimes they’re just, e.g., indices into internal data structures, where you really can’t make any use of them directly.)

#

(it’s sort of like a file descriptor in posix, but more general.)

sour pollen
#

I am passing the unicode text format to the GetClipboardData proc:

ret, _, _ = getDataProc.Call(13)
ret, _, _ = globalLockProc.Call(ret)
// ...
// ret == uintptr
keen zinc
#

then you have a C.wchar_t *

sour pollen
#

So can I just cast ret directly to C.wchar_t?

#
str := (C.wchar_t)(ret)
sour pollen
#

Also, I get possible misuse of unsafe.Pointer unsafeptr(default) with gopls

keen zinc
#

sure

sour pollen
keen zinc
#

it looks fine to me; i knew there was a UTF-16 conversion function somewhere but forgot that it’s only in sys/windows and not syscall