{"id":9023,"date":"2011-11-28T07:00:00","date_gmt":"2011-11-28T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2011\/11\/28\/why-is-clipformat-defined-to-be-a-word-rather-than-a-uint\/"},"modified":"2011-11-28T07:00:00","modified_gmt":"2011-11-28T07:00:00","slug":"why-is-clipformat-defined-to-be-a-word-rather-than-a-uint","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20111128-00\/?p=9023","title":{"rendered":"Why is CLIPFORMAT defined to be a WORD rather than a UINT?"},"content":{"rendered":"<p>Commenter Ivo wants to know <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2008\/04\/30\/8440201.aspx#8443802\"> if the <code>Register&shy;Clipboard&shy;Format<\/code> function returns a <code>UINT<\/code>, why is the <code>CLIP&shy;FORMAT<\/code> data type defined to be a <code>WORD<\/code><\/a>? Since a <code>WORD<\/code> is smaller than a <code>UINT<\/code>, you have to stick in a cast every time you assign the result of <code>Register&shy;Clipboard&shy;Format<\/code> to a <code>CLIP&shy;FORMAT<\/code>.\n Rewind to 16-bit Windows. Back in those days, a <code>UINT<\/code> and a <code>WORD<\/code> were the same size, namely, 16&nbsp;bits. As a result, people got lazy about the distinction. Six of one, a half dozen of the other. (People are lazy about this sort of distinction even today, assuming for example that <code>UINT<\/code> and <code>DWORD<\/code> are the same size, and in turn <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2005\/01\/31\/363790.aspx\"> forcing <code>UINT<\/code> to remain a 32-bit integer type even on 64-bit Windows<\/a>.) The <code>Register&shy;Clipboard&shy;Format<\/code> function came first, and when the OLE folks wanted to define a friendly name for the data type to hold a clipboard format, they said, &#8220;Well, a clipboard format is a 16-bit integer, so let me use a 16-bit integer.&#8221; A <code>WORD<\/code> is a 16-bit integer, so there you go.\n This mismatch had no effect in 16-bit code, but once Win32 showed up, you had a problem since 32-bit Windows expanded the <code>UINT<\/code> type to 32&nbsp;bits. Not only does keeping a <code>CLIP&shy;FORMAT<\/code> in a <code>WORD<\/code> create the need for all this casting, it also leaves two bytes of padding in the <code>FORMAT&shy;ETC<\/code> structure. Strike two.<\/p>\n<p> Yeah, basically, it sucks. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Commenter Ivo wants to know if the Register&shy;Clipboard&shy;Format function returns a UINT, why is the CLIP&shy;FORMAT data type defined to be a WORD? Since a WORD is smaller than a UINT, you have to stick in a cast every time you assign the result of Register&shy;Clipboard&shy;Format to a CLIP&shy;FORMAT. Rewind to 16-bit Windows. Back in [&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":[2],"class_list":["post-9023","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>Commenter Ivo wants to know if the Register&shy;Clipboard&shy;Format function returns a UINT, why is the CLIP&shy;FORMAT data type defined to be a WORD? Since a WORD is smaller than a UINT, you have to stick in a cast every time you assign the result of Register&shy;Clipboard&shy;Format to a CLIP&shy;FORMAT. Rewind to 16-bit Windows. Back in [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/9023","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=9023"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/9023\/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=9023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=9023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=9023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}