{"id":22523,"date":"2008-04-30T10:00:00","date_gmt":"2008-04-30T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2008\/04\/30\/some-other-places-atoms-and-the-magical-0xc000-arise\/"},"modified":"2008-04-30T10:00:00","modified_gmt":"2008-04-30T10:00:00","slug":"some-other-places-atoms-and-the-magical-0xc000-arise","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20080430-00\/?p=22523","title":{"rendered":"Some other places atoms (and the magical 0xC000) arise"},"content":{"rendered":"<p>The moment the Windows developers got a system for converting strings into numbers, they could use it anywhere they need to, well, convert a string into a number. Somtimes these integers are officially declared as atoms, but most of the time they are just integers that happen to be atoms under the covers.\n I&#8217;ll start with registered window messages, created by the <code>RegisterWindowMessage<\/code> function. These are not officially atoms; they are just integers that happen to lie in the range <code>0xC000<\/code> to <code>0xFFFF<\/code>, just like atoms. But yeah, internally, they&#8217;re atoms. Of course, you shouldn&#8217;t rely on it since it&#8217;s not contractual. Think of it as a fantastic coincidence.\n Registered clipboard formats created by the <code>RegisterClipboardFormat<\/code> message are also not officially atoms; they&#8217;re just <code>UINT<\/code>s. The numeric range for registered clipboard formats isn&#8217;t even specified; that they hang out in the <code>0xC000<\/code> range is just an implementation detail. Someday, registered clipboard formats may have values like <code>0x1234<\/code>, who knows.\n Window properties are also stored in the form of atoms, but unlike the other examples above, the atomic nature of window properties is contractual. You can set a property either by passing the property name <code>SetProp(hwnd, TEXT(\"PropertyName\"), hData)<\/code> or by passing the property atom <code>SetProp(hwnd, MAKEINTATOM(atm), hData)<\/code>, where <code>atm<\/code> was obtained from an earlier call to <code>GlobalAddAtom<\/code>. There is additional weirdness with the way these atoms are tracked, which I&#8217;ll defer to Friday&#8217;s article, though it is hinted at in the documentation for <code>SetProp<\/code> which cautions that you need to remove all the properties from a window before it is destroyed.<\/p>\n<p> Window classes also have atoms. The return value of the <code>RegisterClass<\/code> function is an <code>ATOM<\/code>, and you can also retrieve the atom later by calling <code>GetClassWord(GCW_ATOM)<\/code>. We&#8217;ll see more about that atom next time. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The moment the Windows developers got a system for converting strings into numbers, they could use it anywhere they need to, well, convert a string into a number. Somtimes these integers are officially declared as atoms, but most of the time they are just integers that happen to be atoms under the covers. I&#8217;ll start [&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-22523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>The moment the Windows developers got a system for converting strings into numbers, they could use it anywhere they need to, well, convert a string into a number. Somtimes these integers are officially declared as atoms, but most of the time they are just integers that happen to be atoms under the covers. I&#8217;ll start [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/22523","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=22523"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/22523\/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=22523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=22523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=22523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}