In C# you would declare both versions as overloaded methods. And then let the compiler select the appropriate one depending on whether you pass the parameter by value or by ref. However, VB syntax does not allow you to specify whether the parameter is by ref or by value. In C# you have to include ref
or out
and so the overload resolver can use that information to pick the appropriate method.
I think this means that you need to define two methods with different names. For instance:
<DllImport("user32.dll", EntryPoint:="SystemParametersInfo")>
Private Shared Sub SystemParametersInfoByValBoolean(
ByVal uiAction As NativeMethods.SPI,
ByVal uiParam As UInteger,
ByVal pvParam As Boolean,
ByVal fWinIni As NativeMethods.SPIF)
End Sub
<DllImport("user32.dll", EntryPoint:="SystemParametersInfo")>
Private Shared Sub SystemParametersInfoByRefBoolean(
ByVal uiAction As NativeMethods.SPI,
ByVal uiParam As UInteger,
ByRef pvParam As Boolean,
ByVal fWinIni As NativeMethods.SPIF)
End Sub