for example, there is GetWindowTextW if I import windows
proc GetWindowTextW*(wnd: HWND, lpString: LPWSTR, nMaxCount: int32): int32{.stdcall, dynlib: "user32", importc: "GetWindowTextW".}
this function takes an output argument lpString, whose type is LPWSTR in Python there is ctypes.create_unicode_buffer to create such a buffer.
How can I do it in Nim?
Besides, when I compile it, should I add the -d:winUnicode parameter?
var buf = newWideCString("", 4096)
var len = GetWindowTextW(window, cast[LPWSTR](addr buf[0]), 4096)
But I'm not sure if this is the best way. Certainly not the only way.
Thank you for your reply.
I was using a uint16 array since I didn't know the how to cast a type into another. Your way is much cleaner than mine ::)