Using pywin32
according to http://timgolden.me.uk/pywin32-docs/win32com.shell_and_Windows_Shell_Links.html
from win32com.shell import shell
import pythoncom
shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink, None,
pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
)
shortcut.QueryInterface( pythoncom.IID_IPersistFile ).Load( filepath )
Get the Icon path and ID:
>>> print(shortcut.GetIconLocation())
('', 0)
If manually changed:
('%ProgramFiles%\\Blender Foundation\\Blender 3.4\\blender-launcher.exe', 0)
So we need to get the EXE path to resolve the Icon if the path is empty.
See docs for the ENUM supplied.
And I manually pretty printed the result.
>>> print(shortcut.GetPath(shell.SLGP_UNCPRIORITY ))
(
'C:\\Program Files\\Blender Foundation\\Blender 3.4\\blender-launcher.exe',
(
32,
pywintypes.datetime(2022, 12, 20, 2, 2, 52, tzinfo=TimeZoneInfo('GMT Standard Time', True)),
pywintypes.datetime(2023, 1, 16, 10, 30, 16, 724000, tzinfo=TimeZoneInfo('GMT Standard Time', True)),
pywintypes.datetime(2022, 12, 20, 2, 2, 52, tzinfo=TimeZoneInfo('GMT Standard Time', True)),
0,
1079520,
0,
0,
'blender-launcher.exe',
''
)
)
The extra data seems to be from the EXE, see MS Windows Docs: https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-win32_find_dataa