Menu

#222 SHChangeNotify can't be used with SHCNE_ASSOCCHANGED

Unscheduled
closed
nobody
None
Bug
5
2024-04-01
2024-03-20
No

This code in shell.c is incorrect:

case SHCNE_ASSOCCHANGED:
        /* Both dwItem1 and dwItem2 must be NULL (already set) */
        if (! (flags & SHCNF_IDLIST)) {
            /* SDK says this should be set */
            goto invalid_flags_error;
        }
        break;

This doesn't make sense because SHCNF_IDLIST is 0 ( https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.10240.0/um/ShlObj.h#L2675 ) and (! (flags & SHCNF_IDLIST)) is always true.

According to the documentation ( https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shchangenotify#shcnf_idlist ), SHCNF_IDLIST is a type. It can be used as follows:

uFlags - Flags that, when combined bitwise with SHCNF_TYPE, indicate the meaning of the dwItem1 and dwItem2 parameters.

Thus, the correct code to check the type should be something like:

if ( (flags & SHCNF_TYPE) != SHCNF_IDLIST ) ...

However, it may be better to just set the flags to the expected value. I ended up with the following changes: https://github.com/chpock/twapi/commit/b8aa85df43315ca9a7fb089421d365c8bb284634

Discussion

  • Ashok P. Nadkarni

    Thanks. Made a note of this as well. I am currently working on porting twapi to Tcl 9. I'll merge in your fixes once that is in a buildable state.

     
  • Ashok P. Nadkarni

    • status: open --> closed
     
  • Ashok P. Nadkarni

    Fixed in 5.0

     

Anonymous
Anonymous

Add attachments
Cancel