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
Anonymous
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.
Fixed at https://github.com/apnadkarni/twapi/commit/da2ddb3eb45284d05db8adbfa54cb337642bcf9c
Small change in the check as I want any other flag to generate an error. Hope that works for you.
Fixed in 5.0