{"id":28683,"date":"2006-12-18T10:22:04","date_gmt":"2006-12-18T10:22:04","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2006\/12\/18\/some-call-it-context-others-call-it-reference-data-but-whatever-it-is-its-yours\/"},"modified":"2006-12-18T10:22:04","modified_gmt":"2006-12-18T10:22:04","slug":"some-call-it-context-others-call-it-reference-data-but-whatever-it-is-its-yours","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20061218-04\/?p=28683","title":{"rendered":"Some call it context, others call it reference data, but whatever it is, it&#039;s yours"},"content":{"rendered":"<p>Different functions call it different things. <code>RegisterWaitForSingleObject<\/code> calls it <code>Context<\/code>. <code>SetWindowSubclass<\/code> calls it reference data. <code>EnumWindows<\/code> calls it <code>lParam<\/code>. <code>CreateThread<\/code> just calls it a parameter! But whatever its name is,  it means the same thing: It&#8217;s a value the function doesn&#8217;t care about. All the function does is hand that value back to you. What the value means is up to you.\n What if you need to pass more context than a single pointer? What if you want to pass, say, two pointers? Then put the two pointers in a structure and pass a pointer to that structure. When you do this, you introduce lifetime issues, so make sure you have a plan for deciding who is responsible for freeing the memory when it is no longer needed.\n &#8220;Why isn&#8217;t this documented in MSDN? Otherwise, people who call <code>CreateThread<\/code> won&#8217;t know that the parameter needs to be a pointer to this structure and that the thread procedure needs to free the memory.&#8221;<\/p>\n<p> It&#8217;s not documented in MSDN because MSDN doesn&#8217;t care. This is entirely a convention within your program. It&#8217;s your responsibility to ensure that the code that calls <code>CreateThread<\/code> and the thread procedure agree on what the thread parameter means and how it should be managed. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Different functions call it different things. RegisterWaitForSingleObject calls it Context. SetWindowSubclass calls it reference data. EnumWindows calls it lParam. CreateThread just calls it a parameter! But whatever its name is, it means the same thing: It&#8217;s a value the function doesn&#8217;t care about. All the function does is hand that value back to you. What [&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-28683","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Different functions call it different things. RegisterWaitForSingleObject calls it Context. SetWindowSubclass calls it reference data. EnumWindows calls it lParam. CreateThread just calls it a parameter! But whatever its name is, it means the same thing: It&#8217;s a value the function doesn&#8217;t care about. All the function does is hand that value back to you. What [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/28683","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=28683"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/28683\/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=28683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=28683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=28683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}