Enable/disable ClearType in Windows7

前端 未结 8 1388
栀梦
栀梦 2021-01-04 12:00

Hi I need to enable/disable Cleartype (or \"Adjust the appearance and performance of Windows > Smooth edges of screen fonts\") via cmd (or any script like VBS/JS) or from re

8条回答
  •  [愿得一人]
    2021-01-04 12:01

    Just to add more options, I have the C# version, adding GetFontSmoothing to it.

        [DllImport("user32.dll", SetLastError = true)]
        static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref int pvParam, uint fWinIni);
    
        const uint SPI_GETFONTSMOOTHING = 74;
        const uint SPI_SETFONTSMOOTHING = 75;
        const uint SPI_UPDATEINI = 0x1;
        const UInt32 SPIF_UPDATEINIFILE = 0x1;
    
        private Boolean GetFontSmoothing()
        {
            bool iResult;
            int pv = 0;
            /* Call to systemparametersinfo to get the font smoothing value. */
            iResult = SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, ref pv, 0);
            if (pv > 0)
            {
                //pv > 0 means font smoothing is on.
                return true;
            }
            else
            {
                //pv == 0 means font smoothing is off.
                return false;
            }
        }
    
        private void DisableFontSmoothing()
        {
            bool iResult;
            int pv = 0;
            /* Call to systemparametersinfo to set the font smoothing value. */
            iResult = SystemParametersInfo(SPI_SETFONTSMOOTHING, 0, ref pv, SPIF_UPDATEINIFILE);
            Console.WriteLine("Disabled: {0}", iResult);
        }
    
        private void EnableFontSmoothing()
        {
            bool iResult;
            int pv = 0;
            /* Call to systemparametersinfo to set the font smoothing value. */
            iResult = SystemParametersInfo(SPI_SETFONTSMOOTHING, 1, ref pv, SPIF_UPDATEINIFILE);
            Console.WriteLine("Enabled: {0}", iResult);
        }
    

提交回复
热议问题