Answer the question
In order to leave comments, you need to log in
Why doesn't SystemParametersInfo work?
I'm trying to call SystemParametersInfo from C# and change the direction of font smoothing SPI_SETFONTSMOOTHINGORIENTATION I
declared the function like this
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SystemParametersInfo(SPI uiAction, uint uiParam, ref uint pvParam, SPIF fWinIni);
if (SystemParametersInfo(SPI.SPI_SETFONTSMOOTHINGORIENTATION, 0, ref value,
SPIF.SPIF_UPDATEINIFILE | SPIF.SPIF_SENDCHANGE) == false)
{
int code = Marshal.GetLastWin32Error();
return false;
}
[Description("SPI_(System-wide parameter - Used in SystemParametersInfo function )"), Flags]
public enum SPI : uint
{
/// <summary>
/// Determines whether the warning beeper is on.
/// The pvParam parameter must point to a BOOL variable that receives TRUE if the beeper is on, or FALSE if it is off.
/// </summary>
SPI_GETBEEP = 0x0001,
[Description("SPIF_(System-wide parameter - Used in SystemParametersInfo function )"), Flags]
public enum SPIF : uint
{
None = 0x00,
SPIF_UPDATEINIFILE = 0x01,
SPIF_SENDCHANGE = 0x02,
Answer the question
In order to leave comments, you need to log in
Should have declared without ref
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SystemParametersInfo(SPI uiAction, uint uiParam, ref uint pvParam, SPIF fWinIni);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question