{"id":91671,"date":"2015-09-03T07:00:00","date_gmt":"2015-09-03T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20150903-00\/?p=91671\/"},"modified":"2019-03-13T12:19:09","modified_gmt":"2019-03-13T19:19:09","slug":"20150903-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20150903-00\/?p=91671\/","title":{"rendered":"When I change the icon in my shortcut, why doesn&#8217;t it update on the screen?"},"content":{"rendered":"<p>A customer was having trouble updating the icon in one of their shortcuts. Here&#8217;s what they shared with us: <\/p>\n<pre>\n    i_shell_link-&gt;SetIconLocation(icon_file.value().c_str(), 0);\n<\/pre>\n<p>&#8220;Changing the icon from the shortcut property sheet works, but it&#8217;s not working from our code. Is the shortcut property sheet using a different API from <code>IShell&shy;Link::Set&shy;Icon&shy;Location<\/code>? In desperation, we added <\/p>\n<pre>\n    SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);\n<\/pre>\n<p>but that didn&#8217;t help. Did we get the flags to SHChange&shy;Notification<\/code> wrong?&#8221; <\/p>\n<p>The property sheet does use the <code>IShell&shy;Link::Set&shy;Icon&shy;Location<\/code> method to change the shortcut icon. What the customer forgot was to save their changes! <\/p>\n<pre>\n    i_persist_file-&gt;Save(NULL, TRUE);\n<\/pre>\n<p>where <code>i_persist_file<\/code> is the  <code>IPersist&shy;File<\/code> that they used to load the shortcut, or they can use <code>Query&shy;Interface<\/code> to get a new pointer. <\/p>\n<p>The <code>SHCNE_ASSOC&shy;CHANGED<\/code> notification is unnecessary, and in fact it&#8217;s overkill. That&#8217;s like saying, &#8220;I want to change the color of my sofa, so I&#8217;m going to demolish my house, rebuild it, and then refurnish it with a new sofa.&#8221; <\/p>\n<p>If you want to send a notification to say, &#8220;Hey, I updated this file, please go refresh any data you have cached about it,&#8221; you can do a<\/p>\n<pre>\n    SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, fullpath, NULL);\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Dotting all the i&#8217;s.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-91671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Dotting all the i&#8217;s.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/91671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=91671"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/91671\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=91671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=91671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=91671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}