{"id":97986,"date":"2018-02-08T07:00:00","date_gmt":"2018-02-08T22:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=97986"},"modified":"2020-06-13T15:10:15","modified_gmt":"2020-06-13T22:10:15","slug":"20180208-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20180208-00\/?p=97986","title":{"rendered":"What do the output values from CoGetApartmentType mean?"},"content":{"rendered":"<p>The <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd542641(v=vs.85).aspx\"> <code>Co\u00adGet\u00adApartment\u00adType<\/code> function<\/a> returns two pieces of information, documented as follows:<\/p>\n<ul>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms693793(v=vs.85).aspx\"><code>APT\u00adTYPE<\/code><\/a> enumeration value that specifies the type of the current apartment.<\/li>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd542638(v=vs.85).aspx\"><code>APT\u00adTYPE\u00adQUALIFIER<\/code><\/a> enumeration value that specifies the type qualifier of the current apartment.<\/li>\n<\/ul>\n<p>The possible combinations can be deduced from the documentation for <code>APT\u00adTYPE\u00adQUALIFIER<\/code>, but here they are in table form because people like tables.<\/p>\n<table class=\"cp3\" style=\"border-collapse: collapse;\" border=\"1\" cellpadding=\"3\">\n<tbody>\n<tr>\n<th>Apartment Type<\/th>\n<th>Qualifier<\/th>\n<th>Meaning<\/th>\n<\/tr>\n<tr>\n<td>STA<\/td>\n<td>NONE<\/td>\n<td>Single-threaded apartment<\/td>\n<\/tr>\n<tr>\n<td>STA<\/td>\n<td>APPLICATION_STA<\/td>\n<td>Non-reentrant single-threaded apartment<\/td>\n<\/tr>\n<tr>\n<td>MAINSTA<\/td>\n<td>NONE<\/td>\n<td>Main single-threaded apartment<\/td>\n<\/tr>\n<tr>\n<td>MTA<\/td>\n<td>NONE<\/td>\n<td>Multithreaded apartment, explicitly initialized<\/td>\n<\/tr>\n<tr>\n<td>MTA<\/td>\n<td>IMPLICIT<\/td>\n<td>Multithreaded apartment, implicitly initialized<\/td>\n<\/tr>\n<tr>\n<td>NA<\/td>\n<td>NA_ON_STA<\/td>\n<td>Neutral apartment entered on STA thread<\/td>\n<\/tr>\n<tr>\n<td>NA<\/td>\n<td>NA_ON_MAINSTA<\/td>\n<td>Neutral apartment entered on main STA thread<\/td>\n<\/tr>\n<tr>\n<td>NA<\/td>\n<td>NA_ON_MTA<\/td>\n<td>Neutral apartment entered on explicit MTA thread<\/td>\n<\/tr>\n<tr>\n<td>NA<\/td>\n<td>NA_ON_IMPLICIT_MTA<\/td>\n<td>Neutral apartment entered on implicit MTA thread<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>More details can be found in <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd542638(v=vs.85).aspx\"> the documentation for <code>APT\u00adTYPE\u00adQUALIFIER<\/code><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Four types of threads, possibly in the neutral apartment temporarily.<\/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-97986","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Four types of threads, possibly in the neutral apartment temporarily.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97986","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=97986"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97986\/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=97986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=97986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=97986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}