Hello everyone,
I'm trying to get the information about the current overlay icon for a file
on Windows. To get this information I use the SHGetFileInfo function. Here
is my function code:

def get_system_overlay_index_fo_file(path: Path) -> int:
>     flags = shellcon.SHGFI_ICON | 0x000000040  # SHGFI_OVERLAYINDEX
>     file_info = shell.SHGetFileInfo(str(path), 0, flags)
>     return file_info[1][1]  >> 24
>

Docs for reference:

> SHGFI_OVERLAYINDEX (0x000000040)
>
> Version 5.0
> <https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/bb776779(v=vs.85)>.
> Return the index of the overlay icon. The value of the overlay index is
> returned in the *upper eight bits* of the *iIcon* member of the structure
> specified by *psfi*. This flag requires that the *SHGFI_ICON* be set as
> well.
>

The problem is, this function behaves differently in different
environments.
1. In my sandbox project it returns correct icon index.

   - The whole structure returned by SHGetFileInfo: (1, (15535299, 83886083,
   403490781, '', ''))
   - Index:  83886083  >> 24 = 5

 2. However, In the project I'm working on the same function returns
different results. Even if I run them at the same time, for the same file.

   - The whole structure returned by SHGetFileInfo: (1, (15535299, 0,
   403490781, '', ''))
   - Index: 0

After trying to figure it out for a couple of days, I have no more ideas.
Has anyone encountered such behaviour? Why does the same function return
different values for the same input? I would appreciate any feedback or
ideas (or redirection to correct the place where I could ask this question
:)).

Cheers,
Piotr
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to