in header file of DLL I need to wrap is used BSTR data type as I/O parameter. I need to create its mapping in JNA. I have found following example:
class BSTR extends PointerType {
public BSTR() { }
public BSTR(String value) {
super(new Memory(value.length()*2+6).share(4));
getPointer().setInt(-4, value.length()*2);
getPointer().setString(0, value, true);
}
public String toString() {
int length = getPointer().getInt(-4);
char[] data = getPointer().getCharArray(0, length/2);
return new String(data);
}
}
but after using it in JNA method call the result is empty (= length is 0 and no data). Do you have please any suggestions how to create correct mapping for BSTR to use it as I/O param of the function? It looks like the BSTR is not passed by reference to the DLL method so result is still empty but it is only my supposition. Maybe the mapping is correct but is wrongly used in method call. Thank in advance for any suggestion.