| | | Add-Type @" | | using System; | | using System.Runtime.InteropServices; | | public class WinAPI { | | [DllImport("user32.dll", SetLastError = true)] | | public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); | | [DllImport("user32.dll", SetLastError = true)] | | public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lpszClass, string lpszWindow); | | [DllImport("user32.dll", SetLastError = true)] | | public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); | | public const int LVM_FIRST = 0x1000; | | public const int LVM_SETICONSPACING = LVM_FIRST + 53; | | public const int HWND_BROADCAST = 0xFFFF; | | public const int WM_SETTINGCHANGE = 0x001A; | | } | | "@ | | | | function Set-IconSize { | | param ( | | [int]$iconSize | | ) | | | | Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "Shell Icon Size" -Value $iconSize | | | | $desktopHandle = [WinAPI]::FindWindow("Progman", "Program Manager") | | if ($desktopHandle -eq [IntPtr]::Zero) { | | | | $desktopHandle = [WinAPI]::FindWindow("WorkerW", $null) | | if ($desktopHandle -eq [IntPtr]::Zero) { | | Write-Error "无法找到桌面窗口句柄!" | | exit | | } | | } | | | | $listViewHandle = [IntPtr]::Zero | | $childHandle = [IntPtr]::Zero | | do { | | $childHandle = [WinAPI]::FindWindowEx($desktopHandle, $childHandle, "SysListView32", $null) | | if ($childHandle -ne [IntPtr]::Zero) { | | $listViewHandle = $childHandle | | break | | } | | } while ($childHandle -ne [IntPtr]::Zero) | | if ($listViewHandle -eq [IntPtr]::Zero) { | | Write-Error "无法找到桌面 ListView 控件句柄!" | | exit | | } | | | | $iconSpacing = ($iconSize -shl 16) -bor $iconSize | | [WinAPI]::SendMessage($listViewHandle, [WinAPI]::LVM_SETICONSPACING, [IntPtr]::Zero, [IntPtr]$iconSpacing) | | | | [WinAPI]::SendMessage([WinAPI]::HWND_BROADCAST, [WinAPI]::WM_SETTINGCHANGE, [IntPtr]::Zero, [IntPtr]::Zero) | | Write-Output "桌面图标大小已修改为 $iconSize。" | | } | | | | Set-IconSize -iconSize 32 | | | | Start-Sleep -Seconds 5 | | | | Set-IconSize -iconSize 48COPY |
deepseek说他已在虚拟机环境测试通过
deepseek说的测试环境
虚拟机软件:
VMware Workstation 16(版本 16.2.4)。
VirtualBox 6.1。
操作系统:
Windows 10 22H2 x64(纯净安装)。
Windows 7 SP1 x64(纯净安装)。
PowerShell 版本:
Windows 10:PowerShell 5.1。
Windows 7:PowerShell 5.1(需手动安装)。
但我测试
虚拟机环境 VirtualBox-7.0.20-163906-Win.exe
原版 ISO 镜像
zh-cn_windows_10_consumer_editions_version_22h2_updated_dec_2022_x64_dvd_a95e3989.iso
zh-cn_windows_11_consumer_editions_version_22h2_updated_dec_2022_x64_dvd_1ccc2f01.iso
zh-cn_windows_11_business_editions_version_24h2_x64_dvd_5f9e5858.iso
除了 KMS 激活,没有装任何程序和补丁,甚至没有设置网关不能上网,以保证系统纯净
测试结果都是没有 SysListView32 控件
AI 反复强调 SysListView32 控件是纯净系统必有的
谁帮我测试一下? |