{"id":99175,"date":"2018-07-05T07:00:00","date_gmt":"2018-07-05T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=99175"},"modified":"2019-03-13T00:40:00","modified_gmt":"2019-03-13T07:40:00","slug":"20180705-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20180705-00\/?p=99175","title":{"rendered":"How can I detect whether the user is logging off?"},"content":{"rendered":"<p>There may be cases where you want to know whether the user is logging off. For example, your program might be responding to external events by (say) launching a helper program, but you don&#8217;t want to do that if a logoff is in progress. <\/p>\n<p>The way to find out is hidden in <a HREF=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms724385(v=vs.85).aspx\">the <code>Get&shy;System&shy;Metrics<\/code> function<\/a>, which is admittedly a rather non-obvious place to put it. <\/p>\n<pre>\nif (GetSystemMetrics(SM_SHUTTINGDOWN)) {\n \/\/ user is logging off, don't start anything new\n}\n<\/pre>\n<p>Compounding the confusion is that the flag is called &#8220;shutting down&#8221;, but in fact it reports whether the user is logging off (which in today&#8217;s parlance is called <i>signing out<\/i>). The logout may be part of a shutdown, or it might not. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s hidden as a strange sort of system metric.<\/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-99175","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>It&#8217;s hidden as a strange sort of system metric.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99175","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=99175"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99175\/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=99175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=99175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=99175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}