{"id":107978,"date":"2023-03-28T07:00:00","date_gmt":"2023-03-28T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=107978"},"modified":"2023-03-27T19:40:19","modified_gmt":"2023-03-28T02:40:19","slug":"20230328-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20230328-00\/?p=107978","title":{"rendered":"How can I try to escape the disease-ridden hot-tubs known as the TEMP and Downloads directories?"},"content":{"rendered":"<p>Some time ago, I described the TEMP directory as <a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20121031-00\/?p=6203\"> a hot tub whose water hasn&#8217;t been changed in over a year<\/a>. The Downloads folder is in a similar situation: There&#8217;s all sorts of unrelated junk in there, some of which may not be very friendly to your health.<\/p>\n<p>Starting in Windows 10 Version 1607,\u00b9 you can set attributes on your executable to tell the system how to look for the DLLs to which your executable links statically.\u00b2 To do this, pass the <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/reference\/dependentloadflag?view=msvc-160\"> <code>\/DEPENDENTLOADFLAG:nnnn<\/code> command line option<\/a> to the linker, where <code>nnnn<\/code> is a value corresponding to some combination of the <code>LOAD_<wbr \/>LIBRARY_<wbr \/>SEARCH_*<\/code> values that can be passed to the <code>Load\u00adLibrary\u00adEx<\/code> function.<\/p>\n<p>By far the most useful value is <code>LOAD_<wbr \/>LIBRARY_<wbr \/>SEARCH_<wbr \/>SYSTEM32<\/code>, which means &#8220;Look in the system32 directory and nowhere else.&#8221;<\/p>\n<p>To do this, pass <code>\/DEPENDENTLOADFLAG:0x800<\/code>.<\/p>\n<p>Versions of Windows that do not support this option merely ignore it, so it&#8217;s okay to set this option unconditionally.<\/p>\n<p>\u00b9 Windows 10 Version 1607 goes by several other names: The Anniversary Update, Build 14393, and the RS1 release. It&#8217;s kind of silly, really.<\/p>\n<p>\u00b2 Note that the dependent load flag applies only to DLLs that are loaded as a consequence of resolving the module&#8217;s static imports. DLLs loaded dynamically via <code>LoadLibrary<\/code> or <code>LoadLibraryEx<\/code> follow the normal rules.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can ask that dependent DLLs be loaded from the System32 directory.<\/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-107978","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>You can ask that dependent DLLs be loaded from the System32 directory.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/107978","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=107978"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/107978\/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=107978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=107978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=107978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}