Passing Arguments that Can Be Modified by the DLL Function

An argument whose value will be modified by a DLL function needs to be declared using the ByRef keyword.

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
  Function GetCursorPos( ByRef point As Point) As Integer
End Interface
Usage:
Public Sub Main()
  Dim user32Functions As IUserDll32Functions = DllCall.CreateAgentDllCall( Of IUserDll32Functions)()
  Dim point As Point
  user32Functions.GetCursorPos(point)
  MsgBox( "cursor position = (" & point.X & ", " & point.Y & ")" )
End Sub