.net - 如何选择正确的 "network place"图标?

标签 .net powershell environment windows-explorer

我有一个 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。有没有办法从操作系统获取图标详细信息,例如获取对资源管理器命名空间中特殊文件夹的引用?

最佳答案

我的网上邻居有 CLSID 208d2c60-3aea-1069-a2d7-08002b30309d
知道这一点,您可以在 HKEY_CLASSES_ROOT\CLSID\{208D2C60-3AEA-1069-A2D7-08002B30309D}\DefaultIcon 处读取默认注册表值。

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

关于.net - 如何选择正确的 "network place"图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13240672/

相关文章:

java - Spring 3.1配置: environment not injected

.net - 如果垃圾收集器在 Monotouch 4 中为 "more aggressive",这意味着什么?

Powershell批量查找ActiveDirectory对象

powershell - 检查远程计算机上文件中的文本

powershell - 使用 powershell 更新程序集信息

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

c# - WPF 自定义词典仅在 Windows 10 上的 %TEMP% 中创建 .dict 文件

c# - 类库输出类型中的 Npgsql 程序集错误

.net - .NET 是否有向后的 XML 解析器?

python - 已删除的 conda 环境仍然出现在 jupyter-lab 中。我怎样才能删除它们?