Link to home
Start Free TrialLog in
Avatar of HPFE455
HPFE455Flag for United States of America

asked on

How to Refresh Windows Explorer Items using SHChangeNotify

I have the path of a folder, I need to refresh that folder to display the new icon on it.

In the below API, I tried different combinations of parameters, but it seems not working:

SHChangeNotify(SHCNE_UPDATEIMAGE |SHCNE_RENAMEITEM | SHCNE_MKDIR,0, 0, "C:\Watch\Test);
SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HPFE455

ASKER

thanks Sara, I will try your solution tomorrow.
Avatar of HPFE455

ASKER

How shell will know which folder icon need to be changed. I am maintaining a list of folders /Files and that need to be refreshed, so  the updated icon will be displayed.

 The below code is not updating the folde icon.
SHChangeNotify(SHCNE_UPDATEIMAGE, SHCNF_DWORD, 0, idx);
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the QString::utf16 returns const ushort* what is equivalent to const wchar_t * or LPCWSTR (long pointer to "wide" unicode string). unfortunately the third argument of ParseDisplayName is a non-const LPWSTR (or LPOLESTR) though documented as [in] what means read-only. therefore the cast you made which casts from const to non-const is ok.

a solution without cast is like

wchar_t wszbuf[MAX_PATH+1];
wcscpy(wszbuf, path.utf16());
hr =psfParent->ParseDisplayName(NULL,NULL,wszbuf,0, &pidlSystem,NULL); 

Open in new window


Sara
Avatar of HPFE455

ASKER

I have updated my code  after sara's comments and it helped me to resolve the issue