简体   繁体   中英

SHChangeNotify in Windows 10 not updating Quick Access items

It seems like calling SHChangeNotify in Windows does not call an update to the items in the QuickAccess pane (or any custom-namespace folders found on the left side of Explorer). Seems like expanding the tree on the left side to the folder works alright, as well as anything in the main view on the right side.

This will eventually call into a named-pipe that will hook back into our c# code to call an update to the file or folder's icon.

[DllImport("shell32.dll", CharSet = CharSet.Auto)]
private static extern void SHChangeNotify(
    int wEventId,
    uint uFlags,
    IntPtr dwItem1,
    IntPtr dwItem2);

var ptr = Marshal.StringToHGlobalUni(fullPath);
SHChangeNotify((int)SHCNE.SHCNE_UPDATEITEM, (int)(SHCNF.SHCNF_PATHW | SHCNF.SHCNF_FLUSHNOWAIT), ptr, IntPtr.Zero);
Marshal.FreeHGlobal(ptr);

The Quick Access virtual folder path, as a string, is shell:::{679f85cb-0220-4080-b29b-5540cc05aab6} , (this guid name is CLSID_HomeFolder ).

So, you can force a refresh of all items under this virtual folder with a call to:

SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATHW, L"shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}", NULL);

If you want to refresh only a specific set of children, just get the PIDL or the path of these items and call SHChangeNotify(SHCNE_UPDATEITEM, ...) on each.

是否可以在 autoit 上执行此操作?

SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATHW, L"shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}", NULL);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM