{"id":10303,"date":"2011-06-29T07:00:00","date_gmt":"2011-06-29T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2011\/06\/29\/what-happens-to-wparam-lparam-and-lresult-when-they-travel-between-32-bit-and-64-bit-windows\/"},"modified":"2011-06-29T07:00:00","modified_gmt":"2011-06-29T07:00:00","slug":"what-happens-to-wparam-lparam-and-lresult-when-they-travel-between-32-bit-and-64-bit-windows","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20110629-00\/?p=10303","title":{"rendered":"What happens to WPARAM, LPARAM, and LRESULT when they travel between 32-bit and 64-bit windows?"},"content":{"rendered":"<p>\nThe integral types <code>WPARAM<\/code>, <code>LPARAM<\/code>,\nand <code>LRESULT<\/code> are 32 bits wide on 32-bit systems\nand 64 bits wide on 64-bit systems.\nWhat happens when a 32-bit process sends a message to a 64-bit window\nor vice versa?\n<\/p>\n<p>\nThere&#8217;s really only one choice when\nconverting a 64-bit value to a 32-bit value: Truncation.\nWhen a 64-bit process sends a message to a 32-bit window,\nthe 64-bit <code>WPARAM<\/code> and <code>LPARAM<\/code> values\nare truncated to 32 bits.\nSimilarly, when a 64-bit window returns an <code>LRESULT<\/code> back\nto a 32-bit sender, the value is truncated.\n<\/p>\n<p>\nBut converting a 32-bit value to a 64-bit value introduces a choice:\nDo you zero-extend or sign-extend?\n<\/p>\n<p>\nThe answer is obvious if you remember\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2003\/11\/25\/55850.aspx\">\nthe history of <code>WPARAM<\/code>,\n<code>LPARAM<\/code>, and <code>LRESULT<\/code><\/a>,\nor if you just look at the header file.\n<\/p>\n<p>\nThe <code>WPARAM<\/code> is zero-extended,\nwhile <code>LPARAM<\/code> and <code>LRESULT<\/code>\nare sign-extended.\n<\/p>\n<p>\nIf you remember that <code>WPARAM<\/code> used to be a <code>WORD<\/code>\nand <code>LPARAM<\/code> and <code>LRESULT<\/code> used to be <code>LONG<\/code>,\nthen this follows from the fact that <code>WORD<\/code> is an unsigned type\n(therefore zero-extended) and <code>LONG<\/code> is a signed type\n(therefore sign-extended).\n<\/p>\n<p>\nEven if you didn&#8217;t know that, you could look it up in the header file.\n<\/p>\n<pre>\ntypedef UINT_PTR WPARAM;\ntypedef LONG_PTR LPARAM;\ntypedef LONG_PTR LRESULT;\n<\/pre>\n<p>\n<code>UINT_PTR<\/code> is an unsigned type (therefore zero-extended)\nand\n<code>LONG_PTR<\/code> is a signed type (therefore sign-extended).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The integral types WPARAM, LPARAM, and LRESULT are 32 bits wide on 32-bit systems and 64 bits wide on 64-bit systems. What happens when a 32-bit process sends a message to a 64-bit window or vice versa? There&#8217;s really only one choice when converting a 64-bit value to a 32-bit value: Truncation. When a 64-bit [&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-10303","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>The integral types WPARAM, LPARAM, and LRESULT are 32 bits wide on 32-bit systems and 64 bits wide on 64-bit systems. What happens when a 32-bit process sends a message to a 64-bit window or vice versa? There&#8217;s really only one choice when converting a 64-bit value to a 32-bit value: Truncation. When a 64-bit [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/10303","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=10303"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/10303\/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=10303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=10303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=10303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}