Passing Arguments that Can Be Modified by the DLL Function

An argument whose value will be modified by a DLL function needs to be passed either by using an InOutArgument, if the value can be changed, or by using an OutArgument.

Example

This example uses the GetCursorPos function of the user32.dll in order to retrieve the current cursor position.

DLL declaration:
@Dll( "user32.dll" )
public interface IUserDll32Functions {
  int GetCursorPos( OutArgument<Point> point);
}
Usage:
IUserDll32Functions user32Function = DllCall.createAgentDllCall(IUserDll32Functions.class, desktop);
    
OutArgument<Point> point = new OutArgument<Point>(Point.class);
user32Function.GetCursorPos(point);
    
System.out.println("cursor position = " + point.getValue());