{"id":39073,"date":"2004-06-01T07:00:00","date_gmt":"2004-06-01T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/06\/01\/what-does-shgfi_usefileattributes-mean\/"},"modified":"2004-06-01T07:00:00","modified_gmt":"2004-06-01T07:00:00","slug":"what-does-shgfi_usefileattributes-mean","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20040601-00\/?p=39073","title":{"rendered":"What does SHGFI_USEFILEATTRIBUTES mean?"},"content":{"rendered":"<p>One of the flags you can pass to the  <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/shellcc\/platform\/shell\/reference\/functions\/shgetfileinfo.asp\">  SHGetFileInfo<\/a> function is  SHGFI_USEFILEATTRIBUTES.  What does this flag mean?\n  It means, &#8220;Do not access the disk. Pretend that the file\/directory exists,  and that its file attributes are what I passed as the  dwFileAttributes parameter.  Do this  regardless of whether it actually exists or not.&#8221;\n  You can use this flag to get the icon for a file type.  For example, to get the icon for text files, pass a filename of  &#8220;x.txt&#8221;, pass SHGFI_USEFILEATTRIBUTES in the uFlags, and specify  FILE_ATTRIBUTE_NORMAL as the file attributes.\n  Why is the filename &#8220;x.txt&#8221;?  Because you want it to have the extension &#8220;.txt&#8221;, and you want it  to be a valid filename.  (Don&#8217;t pass illegal filenames like  &#8220;???.txt&#8221;.)\n  Why are the file attributes FILE_ATTRIBUTE_NORMAL?  Because you want SHGetFileInfo to pretend that it is a normal file.  (If you passed, say, FILE_ATTRIBUTE_DIRECTORY, then you would have  gotten the folder icon back, since you told the function to pretend  that &#8220;x.txt&#8221; was a directory.)\n  Note that since you are telling SHGetFileInfo to &#8220;pretend&#8221;,  there are some things you lose by the nature of make-believe.<\/p>\n<p>  For example, if the extension is a filetype whose icon changes  depending on the contents of the file,  then the dynamic icon will not be returned since there is no file.  You told the function to &#8220;pretend&#8221;, after all,  and a pretend file has no contents.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the flags you can pass to the SHGetFileInfo function is SHGFI_USEFILEATTRIBUTES. What does this flag mean? It means, &#8220;Do not access the disk. Pretend that the file\/directory exists, and that its file attributes are what I passed as the dwFileAttributes parameter. Do this regardless of whether it actually exists or not.&#8221; You can [&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-39073","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>One of the flags you can pass to the SHGetFileInfo function is SHGFI_USEFILEATTRIBUTES. What does this flag mean? It means, &#8220;Do not access the disk. Pretend that the file\/directory exists, and that its file attributes are what I passed as the dwFileAttributes parameter. Do this regardless of whether it actually exists or not.&#8221; You can [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/39073","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=39073"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/39073\/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=39073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=39073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=39073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}