{"id":35693,"date":"2005-05-06T14:13:32","date_gmt":"2005-05-06T14:13:32","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/05\/06\/how-to-query-properties-of-the-taskbar\/"},"modified":"2005-05-06T14:13:32","modified_gmt":"2005-05-06T14:13:32","slug":"how-to-query-properties-of-the-taskbar","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050506-32\/?p=35693","title":{"rendered":"How to query properties of the taskbar"},"content":{"rendered":"<p>\nOccasionally, people want to query properties of the taskbar.\nI don&#8217;t quite understand why; you should just get on with your\nlife and let the taskbar get on with its life.\nAfter all, there might not even be a taskbar,\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/05\/05\/414910.aspx\">\nas we discussed last time<\/a>.\n<\/p>\n<p>\nBut if you really want to know (perhaps you&#8217;re collecting\nusability data), here&#8217;s how:\n<\/p>\n<pre>\n#include &lt;stdio.h&gt;\n#include &lt;windows.h&gt;\n#include &lt;shellapi.h&gt;\nint __cdecl main(int argc, const char* argv[])\n{\n APPBARDATA abd = { sizeof(abd) };\n UINT uState = (UINT)SHAppBarMessage(ABM_GETSTATE, &amp;abd);\n printf(\"Taskbar on top? %s\\n\",\n        (uState &amp; ABS_ALWAYSONTOP) ? \"yes\" : \"no\");\n printf(\"Taskbar autohide? %s\\n\",\n        (uState &amp; ABS_AUTOHIDE) ? \"yes\" : \"no\");\n return 0;\n}\n<\/pre>\n<p>\nThis little program uses\n<a HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/shellcc\/platform\/shell\/reference\/messages\/abm_getstate.asp\">\nthe <code>ABM_GETSTATE<\/code> message<\/a> of\n<a HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/shellcc\/platform\/shell\/reference\/functions\/shappbarmessage.asp\">\nthe <code>SHAppBarMessage<\/code> function<\/a>\nto get the &#8220;Always on top&#8221; and &#8220;Auto-hide&#8221; properties of the taskbar.\n<\/p>\n<p>\nSince you&#8217;re using the <code>SHAppBarMessage<\/code> function,\nif a future version of Windows changes the way it maintains the taskbar\nstate (or perhaps even changes the name of the taskbar to something else),\nyour program will still work\nbecause the <code>SHAppBarMessage<\/code> function will be kept\nin sync with whatever changes happen to the taskbar.\n<\/p>\n<p>\nYou can also use\n<a HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/shellcc\/platform\/shell\/reference\/messages\/abm_setstate.asp\">\nthe <code>ABM_SETSTATE<\/code> message<\/a>\nto change these states.\nNote that doing so from a program is discouraged;\nthese state bits belong to the user&#8217;s preferences.\nA program shouldn&#8217;t be messing with the user&#8217;s preferences.\n(Well, unless the whole point of the program is to change\nthe user&#8217;s preferences, of course.\nBut the frequency with which I see this question makes me\nwonder whether there really are that many settings-tweaking\nprograms out there.  I suspect people are using this power for evil,\nnot for good.)\n<\/p>\n<p>\nAnd to stave off follow-up questions: These are the only two properties\nof the taskbar that are programmable.  Exposing a programmable interface\nfor something as highly visible as the taskbar is a very sensitive issue,\nbecause once you grant programmatic access to something, there is\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2003\/09\/03\/54760.aspx\">\na very strong temptation for programs to start abusing it<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Occasionally, people want to query properties of the taskbar. I don&#8217;t quite understand why; you should just get on with your life and let the taskbar get on with its life. After all, there might not even be a taskbar, as we discussed last time. But if you really want to know (perhaps you&#8217;re collecting [&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-35693","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Occasionally, people want to query properties of the taskbar. I don&#8217;t quite understand why; you should just get on with your life and let the taskbar get on with its life. After all, there might not even be a taskbar, as we discussed last time. But if you really want to know (perhaps you&#8217;re collecting [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/35693","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=35693"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/35693\/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=35693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=35693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=35693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}