{"id":4523,"date":"2013-04-29T07:00:00","date_gmt":"2013-04-29T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2013\/04\/29\/getting-the-display-name-for-a-shell-property\/"},"modified":"2013-04-29T07:00:00","modified_gmt":"2013-04-29T07:00:00","slug":"getting-the-display-name-for-a-shell-property","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20130429-00\/?p=4523","title":{"rendered":"Getting the display name for a shell property"},"content":{"rendered":"<p><P>\nToday&#8217;s Little Program takes the symbolic name for\na shell property and returns a string\nsuitable for display to the end-user,\ntranslated into the user&#8217;s specified display language.\n<\/P>\n<PRE>\n#include &lt;windows.h&gt;\n#include &lt;ole2.h&gt;\n#include &lt;propsys.h&gt;\n#include &lt;propkey.h&gt;\n#include &lt;atlbase.h&gt;\n#include &lt;atlalloc.h&gt;<\/p>\n<p>int __cdecl wmain(int argc, PWSTR argv[])\n{\n <A HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2004\/05\/20\/135841.aspx\">CCoInitialize<\/A> init;\n if (SUCCEEDED(init) &amp;&amp; argc == 2) {\n  CComPtr&lt;IPropertyDescription&gt; spdesc;\n  if (SUCCEEDED(PSGetPropertyDescriptionByName(\n                   argv[1], IID_PPV_ARGS(&amp;spdesc)))) {\n   CComHeapPtr&lt;wchar_t&gt; spszName;\n   if (SUCCEEDED(spdesc-&gt;GetDisplayName(&amp;spszName))) {\n    wprintf(L&#8221;%ls\\n&#8221;, static_cast&lt;PWSTR&gt;(spszName));\n   }\n  }\n }\n return 0;\n}\n<\/PRE>\n<P>\nRun this program with the string\n<TT>System.Music.Album&shy;Artist<\/TT>\non the command line,\nand the result is the message <TT>Album artist<\/TT>\non English-language systems.\n<\/P>\n<P>\nThe actual workings of the program is pretty straightward.\nWe ask the property system for an interface that describes\nthe property name,\nand ask that interface to give us the display name,\nwhich we print out.\n<\/P>\n<P>\nNothing fancy here.\nThe trick is just knowing that the function exists in the first place.\n<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s Little Program takes the symbolic name for a shell property and returns a string suitable for display to the end-user, translated into the user&#8217;s specified display language. #include &lt;windows.h&gt; #include &lt;ole2.h&gt; #include &lt;propsys.h&gt; #include &lt;propkey.h&gt; #include &lt;atlbase.h&gt; #include &lt;atlalloc.h&gt; int __cdecl wmain(int argc, PWSTR argv[]) { CCoInitialize init; if (SUCCEEDED(init) &amp;&amp; argc == 2) [&hellip;]<\/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-4523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Today&#8217;s Little Program takes the symbolic name for a shell property and returns a string suitable for display to the end-user, translated into the user&#8217;s specified display language. #include &lt;windows.h&gt; #include &lt;ole2.h&gt; #include &lt;propsys.h&gt; #include &lt;propkey.h&gt; #include &lt;atlbase.h&gt; #include &lt;atlalloc.h&gt; int __cdecl wmain(int argc, PWSTR argv[]) { CCoInitialize init; if (SUCCEEDED(init) &amp;&amp; argc == 2) [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/4523","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=4523"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/4523\/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=4523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=4523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=4523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}