Search code examples
javac#dllrefuint

pass an unsigned variable as reference in java for a method implemented in C dll


I have a dll including some methods like this

f(DWORD a, DWORD b, ulong *c)

I have an example of declaring this method in C# as follows

f(uint a, ref uint b, ref IntPtr c)

now I want to implement the same in java. Neither uint nor ref are not supported by java. I added JOOU library to have UInteger but I do not know how to pass it as reference.


Solution

  • Using jna library we can pass IntByReference instead of ref uint. After calling the method we need only to change that to an unsigned value So in java we have

    f(UINT a, IntByReference int_b, PointerByReference c)
    long b = int_b & 0xFFFFFFFFL;