{"id":104422,"date":"2020-11-05T07:00:00","date_gmt":"2020-11-05T15:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=104422"},"modified":"2020-11-05T06:09:04","modified_gmt":"2020-11-05T14:09:04","slug":"20201105-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20201105-00\/?p=104422","title":{"rendered":"What&#8217;s the point of APTTYPE_CURRENT? I mean, of course I&#8217;m current."},"content":{"rendered":"<p>The <code>Co\u00adGet\u00adApartment\u00adType<\/code> function tells you what kind of apartment you are executing in. One of the values in the <code>APTTYPE<\/code> enumeration is <code>APTTYPE_<\/code><code>CURRENT<\/code>. Receiving this value is like walking up to an information desk and asking, &#8220;Where am I?&#8221; and the person at the desk says, &#8220;Why, you&#8217;re right here, of course!&#8221;<\/p>\n<p>The confusion is that the <code>APTTYPE<\/code> enumeration is overloaded for multiple purposes.<\/p>\n<p>It so happens that the <code>Co\u00adGet\u00adApartment\u00adType<\/code> function will never succeed and tell you &#8220;You&#8217;re right here.&#8221;\u00b9<\/p>\n<p>The <code>APTTYPE_<\/code><code>CURRENT<\/code> value is used for functions like <code>Co\u00adGet\u00adDefault\u00adContext<\/code> where you tell it what kind of apartment for which you want to get the default context. If you pass <code>APTTYPE_<\/code><code>CURRENT<\/code>, then you get the default context that corresponds to whatever apartment type you are currently in.<\/p>\n<p>\u00b9 It does use the <code>APTTYPE_<\/code><code>CURRENT<\/code> value for error cases, so that code that forgets to check the error code won&#8217;t mistakenly believe that they are STA or MTA or whatever. If you ask for information about current apartment, but COM hasn&#8217;t been initialized, COM returns <code>CO_<\/code><code>E_<\/code><code>NOT\u00adINITIALIZED<\/code> to tell you &#8220;There is no apartment.&#8221; And if you ignore that error code and look at the <code>APTTYPE<\/code>, it&#8217;ll be <code>APTTYPE_<\/code><code>CURRENT<\/code>: &#8220;Your question made no sense, so I&#8217;ll just say that you&#8217;re right here.&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>No matter where you go, there you are.<\/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-104422","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>No matter where you go, there you are.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104422","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=104422"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104422\/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=104422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=104422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=104422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}