private static void EnsureSystemMetrics() { if (SystemBitDepth == 0) { var hdcDesktop = new HandleRef(null, InteropMethods.GetDC(new HandleRef())); try { var sysBitDepth = InteropMethods.GetDeviceCaps(hdcDesktop, InteropValues.BITSPIXEL); sysBitDepth *= InteropMethods.GetDeviceCaps(hdcDesktop, InteropValues.PLANES); if (sysBitDepth == 8) { sysBitDepth = 4; } var cxSmallIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CXSMICON); var cySmallIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CYSMICON); var cxIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CXICON); var cyIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CYICON); SmallIconSize = new Size(cxSmallIcon, cySmallIcon); IconSize = new Size(cxIcon, cyIcon); SystemBitDepth = sysBitDepth; } finally { InteropMethods.ReleaseDC(new HandleRef(), hdcDesktop); } } }