#Windows API
14 messages · Page 1 of 1 (latest)
(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.)
How would I cast the result to a string?
I am passing the unicode text format to the GetClipboardData proc:
ret, _, _ = getDataProc.Call(13)
ret, _, _ = globalLockProc.Call(ret)
// ...
// ret == uintptr
then you have a C.wchar_t *
This seems to be working, but I am not sure if this is the right approach
ptr := unsafe.Pointer(ret)
str := windows.UTF16PtrToString((*uint16)(ptr))
Also, I get possible misuse of unsafe.Pointer unsafeptr(default) with gopls
sure
Just confirming, do you mean this is valid?
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