【问题标题】:How to choose the right "network place" icon?如何选择合适的“网上邻居”图标?
【发布时间】:2012-11-05 21:28:07
【问题描述】:

我有一个 PowerShell 脚本,可以在登录时创建网络位置的快捷方式。不幸的是,它使用的是旧的低分辨率图标。无论如何,这没什么大不了的,但我想在更高版本的 Windows 中使用更新的图标。

以下是创建快捷方式的函数的相关部分:

# Create the shortcut file

$shortcut = (New-Object -ComObject WScript.Shell).Createshortcut("$shortcutFolder\target.lnk")

$shortcut.TargetPath = $targetPath
if (
$shortcut.IconLocation = "%SystemRoot%\system32\SHELL32.DLL, 275"
$shortcut.Description = $targetPath
$shortcut.WorkingDirectory = $targetPath
$shortcut.Save()

# Set attributes on the files & folders
$desktopIni | Set-ItemProperty -Name Attributes -Value ([IO.FileAttributes]::System -bxor [IO.FileAttributes]::Hidden)
$shortcutFolder | Set-ItemProperty -Name Attributes -Value ([IO.FileAttributes]::ReadOnly)

如您所见,它当前使用的是 SHELL32.DLL 库中的 Icon #275。在 Windows 7 中,“正确”图标是 imageres.dll 中的 Icon #143。有什么方法可以从操作系统获取图标详细信息,例如获取对资源管理器命名空间中特殊文件夹的引用?

【问题讨论】:

  • imageres.dll 中的图标 #143 不适合您?
  • 如果脚本在 Windows XP 机器上运行,它会拉出错误的图标,因为不同版本的索引不同。
  • 为什么不在创建链接之前测试操作系统名称并将编号更改为选择?
  • 我希望不必依赖测试可能有许多我不知道的不同答案的东西。我查找了一份详尽的 Windows 版本号列表,但找不到。

标签: .net powershell environment windows-explorer


【解决方案1】:

网上邻居有 CLSID 208d2c60-3aea-1069-a2d7-08002b30309d

知道了这一点,你就可以读取HKEY_CLASSES_ROOT\CLSID\{208D2C60-3AEA-1069-A2D7-08002B30309D}\DefaultIcon处的默认注册表值了

结果将是%SystemRoot%\system32\imageres.dll,-25

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-05
    • 2013-01-24
    • 1970-01-01
    相关资源
    最近更新 更多