简体   繁体   中英

How to get byte array as return from C byte pointer in JNA

I am using JNA for access to native functions. In my native function one my method is returning byte pointer. How could I get same byte array values as return in JNA? I have tried by getting as string and convert it to bytes but it's not working.

This is my code:

BYTE* GetImageDate(); // in C++

Return a pointer, then use Pointer.getByteArray(0, size) to extract size bytes from the corresponding memory location.

Note that you'll have to somehow figure out what size is, unless the function is returning a NUL-terminated C string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM