【发布时间】:2014-01-13 18:51:02
【问题描述】:
我正在尝试使用SystemParametersInfo 函数来设置布尔参数,这只是我将设置的布尔参数之一的示例:
' I try to set a boolean parameter, but no matter if I use False or True,
' the parameter on the SO is always activated.
SystemParametersInfo(SPI.SPI_SETCURSORSHADOW, 0UI, False, SPIF.None)
' I check the modified parameter but always is positive.
Dim MyBoolean As Boolean = False
SystemParametersInfo(SPI.SPI_GETCURSORSHADOW, 0UI, MyBoolean, SPIF.None)
MsgBox(MyBoolean) ' Always is 'True',
' and in the Advanced properties of the SO;
' the 'Show shadow under mouse' option is always checked.
这是另一个例子:
' Enable Accelerator Keys Visibility ( The underlined keys of the ContextMenu )
NativeMethods.SystemParametersInfo(SPI.SPI_SETKEYBOARDCUES, 0UI, True, SPIF.None)
MSDN 中的文档都说要使用 False 布尔值来禁用参数:
''' <summary>
''' Enables or disables a shadow around the cursor.
''' The pvParam parameter is a BOOL variable.
''' Set pvParam to TRUE to enable the shadow or FALSE to disable the shadow.
''' This effect appears only if the system has a color depth of more than 256 colors.
''' Windows NT, Windows Me/98/95: This value is not supported.
''' </summary>
但事实是,一旦启用它们,我就找不到禁用它们的方法,我尝试直接使用布尔值,也使用布尔变量,并使用 SPIF 参数的组合,没办法,如果我激活一个参数我无法将其关闭,我想我做错了什么但是......是什么?。
PS:我使用的是 Windows 8 x64
这是SystemParametersInfo 部分:
<DllImport("user32.dll", SetLastError:=True)>
Friend Shared Function SystemParametersInfo(
ByVal uiAction As SPI,
ByVal uiParam As UInteger,
ByRef pvParam As Boolean,
ByVal fWinIni As SPIF
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
<Description("SPI System-wide parameter - Used in SystemParametersInfo function")>
Public Enum SPI As UInteger
SPI_SETKEYBOARDCUES = &H100B
SPI_GETCURSORSHADOW = &H101A
SPI_SETCURSORSHADOW = &H101B
End Enum
<Description("SPIF System-wide parameter - Used in SystemParametersInfo function")>
<Flags>
Enum SPIF
''' <summary>
''' None
''' </summary>
None = &H0
''' <summary>
''' Writes the new system-wide parameter setting to the user profile.
''' </summary>
SPIF_UPDATEINIFILE = &H1
''' <summary>
''' Broadcasts the WM_SETTINGCHANGE message after updating the user profile.
''' </summary>
SPIF_SENDCHANGE = &H2
''' <summary>
''' Same as SPIF_SENDCHANGE.
''' </summary>
SPIF_SENDWININICHANGE = &H2
End Enum
【问题讨论】:
标签: .net vb.net windows api winapi