0

I'm making some callbacks but in the DLL that I'm using I got some functions that use another functions as parameters, I already tried to use the interface but I couldn't make it work.

The function in DLL is like:

extern "C" { __declspec(dllexport) DIRET_CALLBACK void RegEnterString(pCallBackEnterString);}

I got an example in C#:

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void _RegEnterString(_CallBackEnterString cbEnterString);
private _RegEnterString dllRegEnterString;

public delegate int _CallBackEnterString(StringBuilder parte1, int tamParte1, StringBuilder parte2, int tamParte2);

1 Answer 1

1

If someone stuck in this same problem.

you need to create an interface to each function that is used as parameter then use the interface to create the reference like the delegates in C#

public interface anInterface extends Library {

   anInterface INSTANCE = (anInterface)Native.loadLibrary("dll"),
    anInterface.class); 

    
    public interface iCallback extends StdCallLibrary.StdCallCallback{
        public int passedFunction(String label);
    }

    public void aFunction(iCallback cb);   
}

you will need to use: import com.sun.jna.win32.StdCallLibrary;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.