Can someone help me with this function? I want to implement
<http://java.io|java.io>.File#path
using Windows native apis. However, I'm not sure which arguments I should supply this function with and how to convert resulting
DWORD
to Kotlin's
String
g
gildor
10/20/2020, 9:42 AM
maybe toKString()? Though, I’m not familiar with WinAPI, toKString() used for standard C strings (arrays)
g
Gieted
10/20/2020, 9:53 AM
This function returns
UInt
, so I guess the result of this function should be put into a buffer, that you pass as an argument. However, I have no idea how to create this buffer and then read value from it
g
gildor
10/20/2020, 10:00 AM
ah I see, you need something like this:
Copy code
val length = 4096
val buffer = allocArray<ByteVar>(length)
GetFullPathNameW(pathname, length, buffer null)
gildor
10/20/2020, 10:10 AM
This will allocate simple bytevar array
Another way is to use Kotlin buffer, something like this: