As a complement of @Plutonix answer I'll share all the SystemParametersInfo
declarations that I needed to write in the past for various purposes.
Usage Example:
' Set Mouse Speed
' ( Minimum: 1, Maximum: 20 )
SystemParametersInfo(SPI.SPI_SETMOUSESPEED, False, 15UI, SPIF.None)
NOTE: I didn't fixed some of the portable warnings that throws the code-analysis tool of VS in the API DataType declarations.
''' <summary>
''' ( For setting a Boolean pvParam )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", SetLastError:=True)>
Friend Shared Function SystemParametersInfo(
ByVal uiAction As SPI,
ByVal uiParam As UInteger,
ByVal pvParam As Boolean,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
''' <summary>
''' ( For getting a Byref Boolean pvParam )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", EntryPoint:="SystemParametersInfo", SetLastError:=True)>
Friend Shared Function SystemParametersInfoByRefpv(
ByVal uiAction As SPI,
ByVal uiParam As UInteger,
ByRef pvParam As Boolean,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
''' <summary>
''' ( For setting a Boolean uiParam and Boolean pvParam parameter )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", SetLastError:=True)>
Friend Shared Function SystemParametersInfo(
ByVal uiAction As SPI,
ByVal uiParam As Boolean,
ByVal pvParam As Boolean,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
''' <summary>
''' ( For setting a IntPtr pvParam parameter )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", SetLastError:=True)>
Friend Shared Function SystemParametersInfo(
ByVal uiAction As SPI,
ByVal uiParam As UInteger,
ByVal pvParam As IntPtr,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
''' <summary>
''' ( For setting an UInteger uiParam and pvParam parameters )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", SetLastError:=True)>
Friend Shared Function SystemParametersInfo(
ByVal uiAction As SPI,
ByVal uiParam As UInteger,
ByVal pvParam As UInteger,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
''' <summary>
''' ( For setting an Boolean uiParam and UInteger pvParam )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", SetLastError:=True)>
Friend Shared Function SystemParametersInfo(
ByVal uiAction As SPI,
ByVal uiParam As Boolean,
ByVal pvParam As UInteger,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
''' <summary>
''' ( For setting a String pvParam parameter )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True, BestFitMapping:=False)>
Friend Shared Function SystemParametersInfo(
ByVal uiAction As UInteger,
ByVal uiParam As UInteger,
ByVal pvParam As String,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
''' <summary>
''' ( For reading a String pvParam parameter )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True, BestFitMapping:=False)>
Friend Shared Function SystemParametersInfo(
ByVal uiAction As UInteger,
ByVal uiParam As UInteger,
ByVal pvParam As StringBuilder,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
''' <summary>
''' ( For setting a AnimationInfo pvParam parameter )
''' Retrieves or sets the value of one of the system-wide parameters.
''' This function can also update the user profile while setting a parameter.
''' </summary>
''' <param name="uiAction">
''' The system-wide parameter to be retrieved or set.
''' </param>
''' <param name="uiParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify zero for this parameter.
''' </param>
''' <param name="pvParam">
''' A parameter whose usage and format depends on the system parameter being queried or set.
''' For more information about system-wide parameters, see the uiAction parameter.
''' If not otherwise indicated, you must specify NULL for this parameter.
''' For information on the PVOID datatype, see Windows Data Types.</param>
''' <param name="fWinIni">
''' If a system parameter is being set, specifies whether the user profile is to be updated,
''' and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to
''' notify them of the change.
''' This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
''' or it can be one or more of the following values.
''' </param>
<DllImport("user32.dll", SetLastError:=True)> _
Friend Shared Function SystemParametersInfo(
ByVal uiAction As SPI,
ByVal uiParam As UInteger,
ByRef pvParam As AnimationInfo,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function