{"id":99825,"date":"2018-09-26T07:00:00","date_gmt":"2018-09-26T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=99825"},"modified":"2019-03-13T00:30:26","modified_gmt":"2019-03-13T07:30:26","slug":"20180926-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20180926-00\/?p=99825","title":{"rendered":"What does the thread parameter to <CODE>Set&shy;Windows&shy;Hook&shy;Ex<\/CODE> actually mean?"},"content":{"rendered":"<p>The <code>Set&shy;Windows&shy;Hook&shy;Ex<\/code> function has a <code>dwThreadId<\/code> parameter for which the documentation says <\/p>\n<blockquote CLASS=\"q\">\n<p>The identifier of the thread with which the hook procedure is to be associated. <\/p>\n<\/blockquote>\n<p>What does it mean for a hook procedure to be &#8220;associated&#8221; with a thread? <\/p>\n<p>Recall that when an event occurs on a thread, the window hook is called from the same thread that the event occurred on. For example, a <code>WH_<\/code><code>CALL&shy;WND&shy;PROC<\/code> hook procedure is called when a window procedure is about to be called, and the call occurs on the thread that is about to call the window procedure. <\/p>\n<p>Okay, there are some window hooks that are global in scope, like the low-level input hooks, but you can&#8217;t install those per-thread anyway, so the issue is moot. <\/p>\n<p>Anyway, if you have a window hook that can be installed per-thread, then it will be installed only for events on that thread. In the above example, it means that only window procedures on that thread will trigger the hook. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>What does it mean to be &#8220;associated&#8221; with a thread?<\/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-99825","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>What does it mean to be &#8220;associated&#8221; with a thread?<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99825","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=99825"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99825\/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=99825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=99825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=99825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}