繁体   English   中英

更改Windows 10字体和缩放设置

[英]Change Windows 10 Font and Zoom Settings

我们的团队正在分发Windows 10,它已经锁定了一些功能,但我们提供了一些自动化功能,其中之一就是更改屏幕分辨率。 我被要求添加更改显示设置, 使文字更大并使一切更大的能力

我遇到的唯一解决方案需要重写注册表项,然后注销然后再重新启动。 此外,我见过的唯一解决方案是使用PowerShell或CMD。 我目前正在使用.NET

我的问题是:

  • 有没有更好的办法? 注册表更改很容易,但我宁愿不强迫用户注销。
  • 无论如何,我宁愿在.NET中这样做,所以想知道是否有人能指出我现有的代码示例,或提供一个。

例1

@echo off
reg add "HKCU\Control Panel\Desktop" /v LogPixels /t reg_dword /d 144
exit /b

例2

cd 'HKCU:\Control Panel\Desktop'
Set-ItemProperty -Path . -Name LogPixels -Value 144
Set-ItemProperty -Path . -Name Win8DpiScaling -Value 1
Set-ItemProperty -Path . -Name FocusBorderHeight -Value 2
Set-ItemProperty -Path . -Name FocusBorderWidth -Value 2
Write-Host 'Sign out and sign back in again to see changes.

未经测试更改设置,但您可以尝试以下功能

function Refresh-Explorer {
    [CmdletBinding()]
    Param()

    $code = @'
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff); 
private const int WM_SETTINGCHANGE = 0x1a; 
private const int SMTO_ABORTIFHUNG = 0x0002; 

[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);

[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)] 
private static extern IntPtr SendMessageTimeout ( IntPtr hWnd, int Msg, IntPtr wParam, string lParam, uint fuFlags, uint uTimeout, IntPtr lpdwResult ); 

[System.Runtime.InteropServices.DllImport("Shell32.dll")] 
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);

public static void Refresh() {
    SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
    SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 3000, IntPtr.Zero); 
}
'@

    Add-Type -MemberDefinition $code -Namespace MyWinAPI -Name Explorer 
    [MyWinAPI.Explorer]::Refresh()
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM