匹配 'Network Location' 个图标
Matching 'Network Location' icons
我正在使用以下代码创建网络位置,但结果与手动执行时的结果并不完全相同。来自 shell32.dll 的图标更小,分辨率更低,并且有一个边框,如左图所示。有什么方法可以使 "native" 外观与 PowerShell 匹配吗?
$linkFolder = New-Item -name:$location.name -path:"$nethoodPath$($location.name)" -type:Directory -errorAction:stop
# Create the ini file
$desktopIniContent = (
'[.ShellClassInfo]',
'CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}',
'Flags=2',
'ConfirmFileOp=1'
) -join "`r`n"
$desktopIniContent | Out-File -filePath:"$nethoodPath$($location.name)\Desktop.ini"
# Create the shortcut file
$link = $shell.Createshortcut("$nethoodPath$($location.name)\target.lnk")
$link.TargetPath = $location.value
$link.IconLocation = "%SystemRoot%\system32\SHELL32.DLL, 275"
$link.Description = $location.value
$link.WorkingDirectory = $location.value
$link.Save()
# Set attributes on the files & folders
Set-ItemProperty "$nethoodPath$($location.name)\Desktop.ini" -name:Attributes -value:([IO.FileAttributes]::System -bxor [IO.FileAttributes]::Hidden) -errorAction:stop
Set-ItemProperty "$nethoodPath$($location.name)" -name:Attributes -value:([IO.FileAttributes]::ReadOnly) -errorAction:stop
右侧的图标可以在imageres.dll
中找到(Windows 图片 res资源库),图标138(索引137):
$link.IconLocation = "%SystemRoot%\system32\imageres,137"
shell32.dll,275
版本的可怕分辨率似乎是 bug/blunder,随后被微软修复:
Windows 7:
shell32.dll
版本扩展性极差
Windows 10:
在 Windows 10 上, shell32.dll,275
缩放到 "Extra Large Icons"-大小非常好
我正在使用以下代码创建网络位置,但结果与手动执行时的结果并不完全相同。来自 shell32.dll 的图标更小,分辨率更低,并且有一个边框,如左图所示。有什么方法可以使 "native" 外观与 PowerShell 匹配吗?
$linkFolder = New-Item -name:$location.name -path:"$nethoodPath$($location.name)" -type:Directory -errorAction:stop
# Create the ini file
$desktopIniContent = (
'[.ShellClassInfo]',
'CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}',
'Flags=2',
'ConfirmFileOp=1'
) -join "`r`n"
$desktopIniContent | Out-File -filePath:"$nethoodPath$($location.name)\Desktop.ini"
# Create the shortcut file
$link = $shell.Createshortcut("$nethoodPath$($location.name)\target.lnk")
$link.TargetPath = $location.value
$link.IconLocation = "%SystemRoot%\system32\SHELL32.DLL, 275"
$link.Description = $location.value
$link.WorkingDirectory = $location.value
$link.Save()
# Set attributes on the files & folders
Set-ItemProperty "$nethoodPath$($location.name)\Desktop.ini" -name:Attributes -value:([IO.FileAttributes]::System -bxor [IO.FileAttributes]::Hidden) -errorAction:stop
Set-ItemProperty "$nethoodPath$($location.name)" -name:Attributes -value:([IO.FileAttributes]::ReadOnly) -errorAction:stop
右侧的图标可以在imageres.dll
中找到(Windows 图片 res资源库),图标138(索引137):
$link.IconLocation = "%SystemRoot%\system32\imageres,137"
shell32.dll,275
版本的可怕分辨率似乎是 bug/blunder,随后被微软修复:
Windows 7:
shell32.dll
版本扩展性极差
Windows 10:
在 Windows 10 上, shell32.dll,275
缩放到 "Extra Large Icons"-大小非常好