Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Integer, _
ByVal uParam As Integer, ByVal lpvParam As Integer, _
ByVal fuWinIni As Integer) As Integer
Notes:
None.
Tips & Tricks:
When using the SPI_GETANIMATION or SPI_SETANIMATION actions, the uiParam value must be set to (System.UInt32)Marshal.SizeOf(typeof(ANIMATIONINFO)).
Sample Code:
// This code works for SPI_GETFOREGROUNDLOCKTIMEOUT, the above signature doesn't. (Ken)
// get current lock timeout value
uint timeout = 99;
bool retVal = SystemParametersInfoGet(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, ref timeout, 0);
// set current lock timeout value to 0, so focus can be grabbed
SystemParametersInfoSet(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0);
SPI_GETNONCLIENTMETRICS is a good way to get user-defined preferences for fonts, colors, icons, etc. There is no other way to do this in .NET as far as I know!
// We can overload this definition, since that's in effect what the unmanaged
// API does anyway.
[DllImport("user32", CharSet=CharSet.Auto)]
private static extern int SystemParametersInfo(int uAction,
int uParam, ref NONCLIENTMETRICS lpvParam, int fuWinIni);
private const int LF_FACESIZE = 32;
// A "logical font" used by old-school windows
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
private struct LOGFONT
{
public int lfHeight;
public int lfWidth;
public int lfEscapement;
public int lfOrientation;
public int lfWeight;
public byte lfItalic;
public byte lfUnderline;
public byte lfStrikeOut;
public byte lfCharSet;
public byte lfOutPrecision;
public byte lfClipPrecision;
public byte lfQuality;
public byte lfPitchAndFamily;
/// <summary>
/// <see cref="UnmanagedType.ByValTStr"/> means that the string
/// should be marshalled as an array of TCHAR embedded in the
/// structure. This implies that the font names can be no larger
/// than <see cref="LF_FACESIZE"/> including the terminating '\0'.
/// That works out to 31 characters.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=LF_FACESIZE)]
public string lfFaceName;
// to shut it up about the warnings
public LOGFONT(string lfFaceName)
{
this.lfFaceName = lfFaceName;
lfHeight = lfWidth = lfEscapement = lfOrientation = lfWeight = 0;
lfItalic = lfUnderline = lfStrikeOut = lfCharSet = lfOutPrecision
= lfClipPrecision = lfQuality = lfPitchAndFamily = 0;
}
}
private struct NONCLIENTMETRICS
{
public int cbSize;
public int iBorderWidth;
public int iScrollWidth;
public int iScrollHeight;
public int iCaptionWidth;
public int iCaptionHeight;
/// <summary>
/// Since <see cref="LOGFONT"/> is a struct instead of a class,
/// we don't have to do any special marshalling here. Much
/// simpler this way.
/// </summary>
public LOGFONT lfCaptionFont;
public int iSMCaptionWidth;
public int iSMCaptionHeight;
public LOGFONT lfSMCaptionFont;
public int iMenuWidth;
public int iMenuHeight;
public LOGFONT lfMenuFont;
public LOGFONT lfStatusFont;
public LOGFONT lfMessageFont;
}
private const int SPI_GETNONCLIENTMETRICS = 41;
OK, so here is how you query for the NONCLIENTMETRICS
Now you can use the font info however you want. Here's how to return a GDI+ Font corresponding to the MessageBox font selected by the user. Note that the height is always negative and always returns "world" units.
return new Font(Metrics.lfMessageFont.lfFaceName,
-Metrics.lfMessageFont.lfHeight,
GraphicsUnit.World);
Changing the wallpaper. Note, only works for BMP. Must convert to BMP format if using JPEG, GIF, etc.
ANIMATIONINFO - Used with SystemParametersInfo for SPI_GETANIMATION or SPI_SETANIMATION
3/16/2007 8:14:53 AM - consultants@russte.com-65.31.114.174
The SystemParametersInfo API
10/30/2013 11:50:28 AM - -212.117.77.91
The SystemParametersInfo API
10/30/2013 11:50:28 AM - -212.117.77.91
The SystemParametersInfo API
10/30/2013 11:50:28 AM - -212.117.77.91
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).